{"id":78949,"date":"2024-09-30T15:16:03","date_gmt":"2024-09-30T08:16:03","guid":{"rendered":"https:\/\/itviec.com\/blog\/?p=78949"},"modified":"2024-09-30T15:16:03","modified_gmt":"2024-09-30T08:16:03","slug":"return-trong-javascript","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/return-trong-javascript\/","title":{"rendered":"Return trong JavaScript: H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng chi ti\u1ebft"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">N\u1ed9i dung b\u00e0i vi\u1ebft<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itviec.com\/blog\/return-trong-javascript\/#Dinh_nghia_ve_return_trong_JavaScript\" >\u0110\u1ecbnh ngh\u0129a v\u1ec1 return trong JavaScript<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itviec.com\/blog\/return-trong-javascript\/#Cau_lenh_return_trong_JavaScript_co_ban\" >C\u00e2u l\u1ec7nh return trong JavaScript c\u01a1 b\u1ea3n<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itviec.com\/blog\/return-trong-javascript\/#Cau_lenh_return_tra_ve_ket_qua_khac_nhau\" >C\u00e2u l\u1ec7nh return tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3 kh\u00e1c nhau<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itviec.com\/blog\/return-trong-javascript\/#Cau_lenh_return_tra_ve_cac_doi_tuong_object\" >C\u00e2u l\u1ec7nh return tr\u1ea3 v\u1ec1 c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng (object)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itviec.com\/blog\/return-trong-javascript\/#Cau_lenh_return_tra_ve_mot_ham_function\" >C\u00e2u l\u1ec7nh return tr\u1ea3 v\u1ec1 m\u1ed9t h\u00e0m (function)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itviec.com\/blog\/return-trong-javascript\/#Cau_lenh_return_thoat_khoi_ham_truoc_thoi_han\" >C\u00e2u l\u1ec7nh return tho\u00e1t kh\u1ecfi h\u00e0m tr\u01b0\u1edbc th\u1eddi h\u1ea1n\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/itviec.com\/blog\/return-trong-javascript\/#Cau_hoi_thuong_gap_ve_return_trong_JavaScript\" >C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 return trong JavaScript<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/itviec.com\/blog\/return-trong-javascript\/#Tong_ket_ve_return_trong_JavaScript\" >T\u1ed5ng k\u1ebft v\u1ec1 return trong JavaScript<\/a><\/li><\/ul><\/nav><\/div>\n<p><em><strong>C\u00e2u l\u1ec7nh return trong JavaScript \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 k\u1ebft th\u00fac vi\u1ec7c th\u1ef1c thi h\u00e0m \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh gi\u00e1 tr\u1ecb c\u1ea7n tr\u1ea3 v\u1ec1 cho h\u00e0m \u0111\u00f3. Hi\u1ec3u r\u00f5 c\u00e1ch s\u1eed d\u1ee5ng return l\u00e0 m\u1ed9t k\u1ef9 n\u0103ng kh\u00f4ng th\u1ec3 thi\u1ebfu \u0111\u1ed1i v\u1edbi b\u1ea5t k\u1ef3 l\u1eadp tr\u00ecnh vi\u00ean JavaScript n\u00e0o.<\/strong><\/em><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ecdc b\u00e0i vi\u1ebft sau \u0111\u1ec3 \u0111\u01b0\u1ee3c t\u00ecm hi\u1ec3u chi ti\u1ebft h\u01a1n v\u1ec1:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\u0110\u1ecbnh ngh\u0129a v\u1ec1 c\u00e2u l\u1ec7nh return trong JavaScript<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1ch s\u1eed d\u1ee5ng c\u00e2u l\u1ec7nh return ph\u1ed5 bi\u1ebfn v\u00e0 m\u1ed9t s\u1ed1 c\u00e2u h\u1ecfi li\u00ean quan v\u1ec1 c\u00e1ch s\u1eed d\u1ee5ng c\u00e2u l\u1ec7nh return<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Dinh_nghia_ve_return_trong_JavaScript\"><\/span><b> \u0110\u1ecbnh ngh\u0129a v\u1ec1 return trong JavaScript<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">C\u00e2u l\u1ec7nh return trong JavaScript \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 k\u1ebft th\u00fac qu\u00e1 tr\u00ecnh th\u1ef1c thi h\u00e0m. N\u1ebfu \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh, m\u1ed9t gi\u00e1 tr\u1ecb nh\u1ea5t \u0111\u1ecbnh s\u1ebd \u0111\u01b0\u1ee3c tr\u1ea3 v\u1ec1 cho function caller. N\u1ebfu bi\u1ec3u th\u1ee9c b\u1ecb b\u1ecf qua, gi\u00e1 tr\u1ecb undefined s\u1ebd \u0111\u01b0\u1ee3c tr\u1ea3 v\u1ec1 thay th\u1ebf.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">function nameOfFunction(){<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0return result \/\/ Gi\u00e1 tr\u1ecb c\u1ea7n \u0111\u01b0\u1ee3c tr\u1ea3 v\u1ec1<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">C\u00e1c h\u00e0m c\u00f3 th\u1ec3 tr\u1ea3 v\u1ec1 nh\u01b0 sau:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Gi\u00e1 tr\u1ecb nguy\u00ean th\u1ee7y (chu\u1ed7i, s\u1ed1, boolean,&#8230;)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1c ki\u1ec3u \u0111\u1ed1i t\u01b0\u1ee3ng (m\u1ea3ng, object, h\u00e0m,&#8230;)<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">C\u00e2u l\u1ec7nh return s\u1ebd kh\u00f4ng tr\u1ea3 v\u1ec1 m\u1ed9t k\u1ebft qu\u1ea3 n\u00e0o \u0111\u00f3 tr\u00ean m\u1ed9t d\u00f2ng m\u1edbi kh\u00f4ng s\u1eed d\u1ee5ng d\u1ea5u ngo\u1eb7c \u0111\u01a1n. \u0110\u00e2y l\u00e0 m\u1ed9t \u0111i\u1ec3m kh\u00e1 k\u1ef3 qu\u1eb7c c\u1ee7a JavaScript v\u00e0 k\u1ebft qu\u1ea3 tr\u1ea3 v\u1ec1 s\u1ebd kh\u00f4ng x\u00e1c \u0111\u1ecbnh. Do \u0111\u00f3, b\u1ea1n c\u1ea7n l\u01b0u \u00fd s\u1eed d\u1ee5ng d\u1ea5u ngo\u1eb7c \u0111\u01a1n khi tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3 tr\u00ean nhi\u1ec1u d\u00f2ng.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">function foo() {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0return\u00a0<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a01;<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">function boo() {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0return (<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a01<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0);<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">foo(); --&gt; kh\u00f4ng x\u00e1c \u0111\u1ecbnh<\/span>\r\n<span style=\"font-weight: 400;\">boo(); --&gt; 1<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Cau_lenh_return_trong_JavaScript_co_ban\"><\/span><b>C\u00e2u l\u1ec7nh return trong JavaScript c\u01a1 b\u1ea3n<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">C\u00e2u l\u1ec7nh return \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3 c\u1ee7a h\u00e0m sau khi n\u00f3 ho\u00e0n t\u1ea5t vi\u1ec7c th\u1ef1c thi.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 nh\u01b0, t\u1ed5ng c\u1ee7a hai s\u1ed1 \u0111\u01b0\u1ee3c tr\u1ea3 v\u1ec1 d\u01b0\u1edbi d\u1ea1ng c\u00e2u l\u1ec7nh return \u0111\u01a1n gi\u1ea3n:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">function sum(firstNumber, secondNumber) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">return firstNumber + secondNumber;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">console.log(sum(1, 2))<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Qua v\u00ed d\u1ee5 tr\u00ean, v\u1edbi t\u1ed5ng c\u1ee7a hai s\u1ed1 1 v\u00e0 2 s\u1ebd \u0111\u01b0\u1ee3c th\u1ef1c thi v\u1edbi k\u1ebft qu\u1ea3 hi\u1ec3n th\u1ecb l\u00e0 3 tr\u00ean tr\u00ecnh duy\u1ec7t.<\/span><b><\/b><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Cau_lenh_return_tra_ve_ket_qua_khac_nhau\"><\/span><b>C\u00e2u l\u1ec7nh return tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3 kh\u00e1c nhau<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">H\u00e0m trong JavaScript kh\u00f4ng ch\u1ec9 gi\u1edbi h\u1ea1n ho\u1eb7c b\u1ecb r\u00e0ng bu\u1ed9c \u0111\u1ec3 tr\u1ea3 v\u1ec1 c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u c\u1ee5 th\u1ec3, m\u00e0 c\u00f2n c\u00f3 th\u1ec3 tr\u1ea3 v\u1ec1 c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u kh\u00e1c nhau d\u1ef1a tr\u00ean logic \u0111\u01b0\u1ee3c x\u00e1c \u0111\u1ecbnh b\u00ean trong h\u00e0m.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5: Minh h\u1ecda v\u1ec1 ki\u1ec3u d\u1eef li\u1ec7u tr\u1ea3 v\u1ec1 chu\u1ed7i, s\u1ed1 v\u00e0 m\u1ea3ng<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">\/\/ tr\u1ea3 v\u1ec1 ki\u1ec3u d\u1eef li\u1ec7u chu\u1ed7i<\/span>\r\n<span style=\"font-weight: 400;\">getStringValue() {<\/span>\r\n<span style=\"font-weight: 400;\">return \"ITviec Blog\";<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n<span style=\"font-weight: 400;\">\/\/ tr\u1ea3 v\u1ec1 ki\u1ec3u d\u1eef li\u1ec7u s\u1ed1<\/span>\r\n<span style=\"font-weight: 400;\">getNumberValue() {<\/span>\r\n<span style=\"font-weight: 400;\">return 2015;<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\/\/ tr\u1ea3 v\u1ec1 m\u1ea3ng<\/span>\r\n<span style=\"font-weight: 400;\">getArrayValue() {<\/span>\r\n<span style=\"font-weight: 400;\">return [1, 2, 3, 4, 5];<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">console.log(` returned value is ${getStringValue()} \\n`);<\/span>\r\n<span style=\"font-weight: 400;\">console.log(` returned value is ${getNumberValue()} \\n`);<\/span>\r\n<span style=\"font-weight: 400;\">console.log(` returned value is ${getArrayValue()} \\n`);<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Trong \u0111\u00f3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e2u l\u1ec7nh return \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 tr\u1ea3 v\u1ec1 m\u1ed9t gi\u00e1 tr\u1ecb c\u1ee5 th\u1ec3 trong h\u00e0m, nh\u01b0 value() l\u00e0 ITviec Blog, number() l\u00e0 2015 v\u00e0 array() l\u00e0 1,2,3,4,5.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1c c\u00e2u l\u1ec7nh console.log() \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 in ra gi\u00e1 tr\u1ecb tr\u1ea3 v\u1ec1 c\u1ee7a c\u00e1c h\u00e0m.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Gi\u00e1 tr\u1ecb tr\u1ea3 v\u1ec1 c\u1ee7a m\u1ed7i h\u00e0m \u0111\u01b0\u1ee3c \u0111\u1eb7t trong d\u1ea5u ngo\u1eb7c nh\u1ecdn {} v\u00e0 \u0111\u01b0\u1ee3c ch\u00e8n v\u00e0o chu\u1ed7i b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng to\u00e1n t\u1eed ${}<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3 hi\u1ec3n th\u1ecb nh\u01b0 sau:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">returned value is ITviec Blog\u00a0\u00a0<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">returned value is 2015\u00a0<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">returned value is 1,2,3,4,5<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span class=\"ez-toc-section\" id=\"Cau_lenh_return_tra_ve_cac_doi_tuong_object\"><\/span><b>C\u00e2u l\u1ec7nh return tr\u1ea3 v\u1ec1 c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng (object)<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">C\u00e1c h\u00e0m JavaScript c\u0169ng cho ph\u00e9p b\u1ea1n tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3 \u0111\u1ed1i t\u01b0\u1ee3ng gi\u00fap \u1ea9n d\u1eef li\u1ec7u v\u00e0 c\u00e1c h\u00e0nh vi li\u00ean quan.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Ch\u1eb3ng h\u1ea1n nh\u01b0 v\u00ed d\u1ee5 sau, tr\u1ea3 v\u1ec1 \u0111\u1ed1i t\u01b0\u1ee3ng c\u00f4ng ty b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng c\u00e2u l\u1ec7nh return.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">function<\/span> <span style=\"font-weight: 400;\">createCompany<\/span><span style=\"font-weight: 400;\">(name, founded, location) {<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">let<\/span><span style=\"font-weight: 400;\"> company = {<\/span>\r\n <span style=\"font-weight: 400;\">name: name,<\/span>\r\n <span style=\"font-weight: 400;\">founded: founded,<\/span>\r\n <span style=\"font-weight: 400;\">location: location,<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0 };<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0 <\/span><span style=\"font-weight: 400;\">return<\/span><span style=\"font-weight: 400;\"> company;<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n<span style=\"font-weight: 400;\">let<\/span><span style=\"font-weight: 400;\"> companyObject = createCompany(<\/span><span style=\"font-weight: 400;\">'ITviec'<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">2013<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">'Ho Chi Minh City'<\/span><span style=\"font-weight: 400;\">);<\/span>\r\n<span style=\"font-weight: 400;\">console<\/span><span style=\"font-weight: 400;\">.log(<\/span><span style=\"font-weight: 400;\">'Company'<\/span><span style=\"font-weight: 400;\">, companyObject);<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Trong \u0111o\u1ea1n m\u00e3 n\u00e0y, c\u00e2u l\u1ec7nh return \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 tr\u1ea3 v\u1ec1 m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng t\u1eeb h\u00e0m <\/span><span style=\"font-weight: 400;\">Object()<\/span><span style=\"font-weight: 400;\">. \u0110\u1ed1i t\u01b0\u1ee3ng n\u00e0y \u0111\u01b0\u1ee3c t\u1ea1o ra b\u00ean trong h\u00e0m v\u00e0 ch\u1ee9a c\u00e1c thu\u1ed9c t\u00ednh <\/span><span style=\"font-weight: 400;\">name, founded v\u00e0 location<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Khi th\u1ef1c hi\u1ec7n c\u00e2u l\u1ec7nh, \u0111\u1ed1i t\u01b0\u1ee3ng <\/span><span style=\"font-weight: 400;\">companyobject<\/span><span style=\"font-weight: 400;\"> \u0111\u01b0\u1ee3c in ra tr\u00ean m\u00e0n h\u00ecnh console b\u1eb1ng c\u00e2u l\u1ec7nh <\/span><span style=\"font-weight: 400;\">console.log(companyobject).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3 hi\u1ec3n th\u1ecb nh\u01b0 sau:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<p style=\"text-align: left;\"><span style=\"font-family: inherit; font-size: inherit;\"><span style=\"font-weight: 400;\">{name: &#8216;ITviec\u2019, founded: 2013, location: &#8216;Ho Chi Minh City&#8217;}<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span class=\"ez-toc-section\" id=\"Cau_lenh_return_tra_ve_mot_ham_function\"><\/span><b>C\u00e2u l\u1ec7nh return tr\u1ea3 v\u1ec1 m\u1ed9t h\u00e0m (function)<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">JavaScript c\u00f3 kh\u00e1i ni\u1ec7m v\u1ec1 c\u00e1c h\u00e0m b\u1eadc cao cho ph\u00e9p b\u1ea1n truy\u1ec1n m\u1ed9t h\u00e0m kh\u00e1c l\u00e0m \u0111\u1ed1i s\u1ed1 b\u00ean trong m\u1ed9t h\u00e0m ho\u1eb7c tr\u1ea3 v\u1ec1 m\u1ed9t h\u00e0m kh\u00e1c ho\u1eb7c c\u1ea3 hai. C\u01a1 ch\u1ebf n\u00e0y c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 t\u1ea1o m\u1ed9t h\u00e0m c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng v\u1edbi h\u00e0nh vi c\u1ee5 th\u1ec3 v\u00e0 cho ph\u00e9p t\u1ea1o ra closure.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 nh\u01b0 s\u1eed d\u1ee5ng c\u00e2u l\u1ec7nh return \u0111\u1ec3 tr\u1ea3 v\u1ec1 m\u1ed9t h\u00e0m nh\u01b0 sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">function getBlogFunction() {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">return function () {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">return \"ITviec Blog\";<\/span>\r\n\r\n<span style=\"font-weight: 400;\">};<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">console.log(getBlogFunction()());<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Cau_lenh_return_thoat_khoi_ham_truoc_thoi_han\"><\/span><b>C\u00e2u l\u1ec7nh return tho\u00e1t kh\u1ecfi h\u00e0m tr\u01b0\u1edbc th\u1eddi h\u1ea1n\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">C\u00e2u l\u1ec7nh return c\u0169ng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 tho\u00e1t kh\u1ecfi h\u00e0m s\u1edbm trong JavaScript trong nh\u1eefng tr\u01b0\u1eddng h\u1ee3p \u0111i\u1ec1u ki\u1ec7n \u0111\u01b0\u1ee3c \u0111\u00e1p \u1ee9ng.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5, s\u1eed d\u1ee5ng c\u00e2u l\u1ec7nh return \u0111\u1ec3 tho\u00e1t kh\u1ecfi h\u00e0m s\u1edbm d\u1ef1a tr\u00ean c\u00e1c \u0111i\u1ec1u ki\u1ec7n nh\u1ea5t \u0111\u1ecbnh<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">function isDivisible(<\/span><i><span style=\"font-weight: 400;\">number<\/span><\/i><span style=\"font-weight: 400;\">)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">{<\/span>\r\n\r\n<span style=\"font-weight: 400;\">if(number%2===0)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">{<\/span>\r\n\r\n<span style=\"font-weight: 400;\">return true;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">return false;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">console.log(`S\u1ed1 chia h\u1ebft cho 2:${isDivisible(107)}`)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">console.log(`S\u1ed1 kh\u00f4ng chia h\u1ebft cho 2:${isDivisible(24)}`)<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Trong \u0111o\u1ea1n m\u00e3 n\u00e0y, c\u00e2u l\u1ec7nh return \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 tr\u1ea3 v\u1ec1 m\u1ed9t gi\u00e1 tr\u1ecb boolean (true ho\u1eb7c false) t\u1eeb h\u00e0m <\/span><span style=\"font-weight: 400;\">isDivisible()<\/span><span style=\"font-weight: 400;\">. Gi\u00e1 tr\u1ecb tr\u1ea3 v\u1ec1 ph\u1ee5 thu\u1ed9c v\u00e0o \u0111i\u1ec1u ki\u1ec7n ki\u1ec3m tra s\u1ed1 c\u00f3 chia h\u1ebft cho 2 hay kh\u00f4ng.\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">H\u00e0m <\/span><span style=\"font-weight: 400;\">inDivisible()<\/span><span style=\"font-weight: 400;\">nh\u1eadn m\u1ed9t tham s\u1ed1 number, c\u00e2u l\u1ec7nh \u0111i\u1ec1u ki\u1ec7n if b\u00ean trong ki\u1ec3m tra xem number c\u00f3 chia h\u1ebft cho 2 hay kh\u00f4ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">N\u1ebfu s\u1ed1 chia h\u1ebft cho 2, k\u1ebft qu\u1ea3 tr\u1ea3 v\u1ec1 true. N\u1ebfu kh\u00f4ng chia h\u1ebft cho 2, k\u1ebft qu\u1ea3 tr\u1ea3 v\u1ec1 false.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Hai c\u00e2u l\u1ec7nh <\/span><span style=\"font-weight: 400;\">console.log()<\/span><span style=\"font-weight: 400;\"> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 in ra k\u1ebft qu\u1ea3 c\u1ee7a h\u00e0m <\/span><span style=\"font-weight: 400;\">isDivisible() <\/span><span style=\"font-weight: 400;\">cho hai s\u1ed1 kh\u00e1c nhau.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">K\u1ebft qu\u1ea3 hi\u1ec3n th\u1ecb nh\u01b0 sau:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">S\u1ed1 chia h\u1ebft cho 2: false<\/span><\/p>\n<p style=\"text-align: left;\"><span style=\"font-weight: 400;\">S\u1ed1 kh\u00f4ng chia h\u1ebft cho 2: true<\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span class=\"ez-toc-section\" id=\"Cau_hoi_thuong_gap_ve_return_trong_JavaScript\"><\/span><b>C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 return trong JavaScript<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>M\u1ed9t h\u00e0m JavaScript c\u00f3 th\u1ec3 c\u00f3 nhi\u1ec1u c\u00e2u l\u1ec7nh return kh\u00f4ng?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">C\u00e2u tr\u1ea3 l\u1eddi l\u00e0 c\u00f3 th\u1ec3. M\u1ed9t h\u00e0m c\u00f3 th\u1ec3 c\u00f3 nhi\u1ec1u c\u00e2u l\u1ec7nh return trong c\u00e1c kh\u1ed1i c\u00f3 \u0111i\u1ec1u ki\u1ec7n, nh\u01b0ng ch\u1ec9 c\u00f3 m\u1ed9t l\u1ec7nh return \u0111\u01b0\u1ee3c th\u1ef1c thi cho m\u1ed7i l\u1ec7nh g\u1ecdi h\u00e0m.<\/span><b><\/b><\/p>\n<h3><b>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa return v\u00e0 console.log l\u00e0 g\u00ec?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">S\u1ef1 kh\u00e1c bi\u1ec7t d\u1ec5 nh\u1eadn th\u1ea5y \u1edf c\u00e2u l\u1ec7nh return v\u00e0 console.log ch\u00ednh l\u00e0 return tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb t\u1eeb m\u1ed9t h\u00e0m cho caller. Trong khi console.log hi\u1ec3n th\u1ecb gi\u00e1 tr\u1ecb trong b\u1ea3ng \u0111i\u1ec1u khi\u1ec3n c\u1ee7a tr\u00ecnh duy\u1ec7t m\u00e0 kh\u00f4ng k\u1ebft th\u00fac qu\u00e1 tr\u00ecnh th\u1ef1c thi h\u00e0m.<\/span><b><\/b><\/p>\n<h3><b>C\u00f3 th\u1ec3 s\u1eed d\u1ee5ng return b\u00ean ngo\u00e0i m\u1ed9t h\u00e0m trong JavaScript kh\u00f4ng?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">C\u00e2u tr\u1ea3 l\u1eddi l\u00e0 kh\u00f4ng. B\u1edfi v\u00ec c\u00e2u l\u1ec7nh return ch\u1ec9 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng b\u00ean trong c\u00e1c h\u00e0m, n\u1ebfu s\u1eed d\u1ee5ng b\u00ean ngo\u00e0i m\u1ed9t h\u00e0m s\u1ebd d\u1ec5 d\u1eabn \u0111\u1ebfn l\u1ed7i c\u00fa ph\u00e1p.\u00a0<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Tong_ket_ve_return_trong_JavaScript\"><\/span><b>T\u1ed5ng k\u1ebft v\u1ec1 return trong JavaScript<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">C\u00e2u l\u1ec7nh <\/span><b>return trong JavaScript<\/b><span style=\"font-weight: 400;\"> l\u00e0 m\u1ed9t trong nh\u1eefng kh\u00e1i ni\u1ec7m c\u01a1 b\u1ea3n cho ph\u00e9p \u0111i\u1ec1u khi\u1ec3n lu\u1ed3ng th\u1ef1c thi c\u1ee7a h\u00e0m v\u00e0 tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb. S\u1eed d\u1ee5ng c\u00e2u l\u1ec7nh return m\u1ed9t c\u00e1ch linh ho\u1ea1t gi\u00fap b\u1ea1n vi\u1ebft c\u00e1c h\u00e0m v\u00e0 t\u1ed1i \u01b0u h\u00f3a qu\u00e1 tr\u00ecnh th\u1ef1c thi m\u00e3 hi\u1ec7u qu\u1ea3.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">B\u1ea1n c\u00f3 th\u1ec3 k\u1ebft h\u1ee3p theo d\u00f5i nh\u1eefng b\u00e0i vi\u1ebft c\u01a1 b\u1ea3n v\u1ec1 c\u00e1c ph\u01b0\u01a1ng th\u1ee9c trong JavaScript sau:<\/span><\/p>\n<ul>\n<li><a href=\"https:\/\/itviec.com\/blog\/if-trong-javascript\/\" target=\"_blank\" rel=\"noopener\">H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng c\u00e1c l\u1ec7nh if trong JavaScript chi ti\u1ebft<\/a><\/li>\n<li><a href=\"https:\/\/itviec.com\/blog\/khai-bao-bien-trong-javascript\/\" target=\"_blank\" rel=\"noopener\">Khai b\u00e1o bi\u1ebfn trong JavaScript: Chi ti\u1ebft c\u00e1c c\u00e1ch ph\u1ed5 bi\u1ebfn<\/a><\/li>\n<li><a href=\"https:\/\/itviec.com\/blog\/vong-lap-trong-javascript\/\" target=\"_blank\" rel=\"noopener\">V\u00f2ng l\u1eb7p trong JavaScript: Chi ti\u1ebft 8 ph\u01b0\u01a1ng th\u1ee9c l\u1eb7p k\u00e8m v\u00ed d\u1ee5<\/a><\/li>\n<li><a href=\"https:\/\/itviec.com\/blog\/foreach-javascript-la-gi\/\" target=\"_blank\" rel=\"noopener\">forEach JavaScript: M\u1ed9t s\u1ed1 thao t\u00e1c c\u01a1 b\u1ea3n v\u00e0 v\u00ed d\u1ee5 chi ti\u1ebft<\/a><\/li>\n<li><a href=\"https:\/\/itviec.com\/blog\/array-javascript-la-gi\/\" target=\"_blank\" rel=\"noopener\">Array JavaScript: T\u1ed5ng h\u1ee3p 12 ph\u01b0\u01a1ng th\u1ee9c quan tr\u1ecdng c\u1ee7a array<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>C\u00e2u l\u1ec7nh return trong JavaScript \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 k\u1ebft th\u00fac vi\u1ec7c th\u1ef1c thi h\u00e0m \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh gi\u00e1 tr\u1ecb c\u1ea7n tr\u1ea3 v\u1ec1 cho h\u00e0m \u0111\u00f3. Hi\u1ec3u r\u00f5 c\u00e1ch s\u1eed d\u1ee5ng return l\u00e0 m\u1ed9t k\u1ef9 n\u0103ng kh\u00f4ng th\u1ec3 thi\u1ebfu \u0111\u1ed1i v\u1edbi b\u1ea5t k\u1ef3 l\u1eadp tr\u00ecnh vi\u00ean JavaScript n\u00e0o. \u0110\u1ecdc b\u00e0i vi\u1ebft sau \u0111\u1ec3 \u0111\u01b0\u1ee3c t\u00ecm [&hellip;]<\/p>\n","protected":false},"author":207,"featured_media":79227,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109],"tags":[],"class_list":["post-78949","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it"],"blocksy_meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Return trong JavaScript: H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng chi ti\u1ebft - ITviec Blog<\/title>\n<meta name=\"description\" content=\"Return trong JavaScript \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 d\u1eebng th\u1ef1c thi h\u00e0m v\u00e0 t\u00f9y ch\u1ecdn tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh. N\u1eafm v\u1eefng c\u00e2u l\u1ec7nh return ngay sau \u0111\u00e2y!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itviec.com\/blog\/return-trong-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Return trong JavaScript: H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng chi ti\u1ebft\" \/>\n<meta property=\"og:description\" content=\"C\u00e2u l\u1ec7nh return trong JavaScript \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 k\u1ebft th\u00fac vi\u1ec7c th\u1ef1c thi h\u00e0m \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh gi\u00e1 tr\u1ecb c\u1ea7n tr\u1ea3 v\u1ec1 cho h\u00e0m \u0111\u00f3. Hi\u1ec3u r\u00f5 c\u00e1ch s\u1eed d\u1ee5ng return l\u00e0 m\u1ed9t\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/return-trong-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"ITviec Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ITviec\" \/>\n<meta property=\"article:published_time\" content=\"2024-09-30T08:16:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/09\/return-trong-JavaScript-vippro.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1500\" \/>\n\t<meta property=\"og:image:height\" content=\"790\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Uyen Ngo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ITviec\" \/>\n<meta name=\"twitter:site\" content=\"@ITviec\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"Uyen Ngo\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Return trong JavaScript: H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng chi ti\u1ebft - ITviec Blog","description":"Return trong JavaScript \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 d\u1eebng th\u1ef1c thi h\u00e0m v\u00e0 t\u00f9y ch\u1ecdn tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh. N\u1eafm v\u1eefng c\u00e2u l\u1ec7nh return ngay sau \u0111\u00e2y!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itviec.com\/blog\/return-trong-javascript\/","og_locale":"vi_VN","og_type":"article","og_title":"Return trong JavaScript: H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng chi ti\u1ebft","og_description":"C\u00e2u l\u1ec7nh return trong JavaScript \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 k\u1ebft th\u00fac vi\u1ec7c th\u1ef1c thi h\u00e0m \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh gi\u00e1 tr\u1ecb c\u1ea7n tr\u1ea3 v\u1ec1 cho h\u00e0m \u0111\u00f3. Hi\u1ec3u r\u00f5 c\u00e1ch s\u1eed d\u1ee5ng return l\u00e0 m\u1ed9t","og_url":"https:\/\/itviec.com\/blog\/return-trong-javascript\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2024-09-30T08:16:03+00:00","og_image":[{"width":1500,"height":790,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/09\/return-trong-JavaScript-vippro.jpg","type":"image\/jpeg"}],"author":"Uyen Ngo","twitter_card":"summary_large_image","twitter_creator":"@ITviec","twitter_site":"@ITviec","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"Uyen Ngo","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"7 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/return-trong-javascript\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/return-trong-javascript\/"},"author":{"name":"Uyen Ngo","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/f4cd1226846e0258c664e170d3e52d20"},"headline":"Return trong JavaScript: H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng chi ti\u1ebft","datePublished":"2024-09-30T08:16:03+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/return-trong-javascript\/"},"wordCount":1621,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/return-trong-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/09\/return-trong-JavaScript-vippro.jpg","articleSection":["Chuy\u00ean m\u00f4n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/return-trong-javascript\/","url":"https:\/\/itviec.com\/blog\/return-trong-javascript\/","name":"Return trong JavaScript: H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng chi ti\u1ebft - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/return-trong-javascript\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/return-trong-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/09\/return-trong-JavaScript-vippro.jpg","datePublished":"2024-09-30T08:16:03+00:00","description":"Return trong JavaScript \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 d\u1eebng th\u1ef1c thi h\u00e0m v\u00e0 t\u00f9y ch\u1ecdn tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh. N\u1eafm v\u1eefng c\u00e2u l\u1ec7nh return ngay sau \u0111\u00e2y!","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/return-trong-javascript\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/return-trong-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/return-trong-javascript\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/09\/return-trong-JavaScript-vippro.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/09\/return-trong-JavaScript-vippro.jpg","width":1500,"height":790,"caption":"return trong JavaScript - itviec blog"},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/return-trong-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Chuy\u00ean m\u00f4n IT","item":"https:\/\/itviec.com\/blog\/chuyen-mon-it\/"},{"@type":"ListItem","position":2,"name":"Return trong JavaScript: H\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng chi ti\u1ebft"}]},{"@type":"WebSite","@id":"https:\/\/itviec.com\/blog\/#website","url":"https:\/\/itviec.com\/blog\/","name":"ITviec Blog","description":"IT Jobs &amp; People in Vietnam","publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itviec.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/itviec.com\/blog\/#organization","name":"ITviec","url":"https:\/\/itviec.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","width":1800,"height":1800,"caption":"ITviec"},"image":{"@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ITviec","https:\/\/x.com\/ITviec","https:\/\/www.linkedin.com\/company\/itviec","https:\/\/www.youtube.com\/channel\/UCYthAQ3bcGr57M_ag5gHDvQ"]},{"@type":"Person","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/f4cd1226846e0258c664e170d3e52d20","name":"Uyen Ngo","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/ngo-thieu-my-uyen-author-e1709880420317-100x100.jpg","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/ngo-thieu-my-uyen-author-e1709880420317-100x100.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/ngo-thieu-my-uyen-author-e1709880420317-100x100.jpg","caption":"Uyen Ngo"},"url":"https:\/\/itviec.com\/blog\/author\/uyen-ngo\/"}]}},"_links":{"self":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/78949","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/users\/207"}],"replies":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/comments?post=78949"}],"version-history":[{"count":0,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/78949\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/79227"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=78949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=78949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=78949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}