{"id":90106,"date":"2025-09-01T18:25:57","date_gmt":"2025-09-01T11:25:57","guid":{"rendered":"https:\/\/itviec.com\/blog\/?p=90106"},"modified":"2025-09-01T18:25:59","modified_gmt":"2025-09-01T11:25:59","slug":"null-vs-undefined-javascript","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/","title":{"rendered":"Null vs undefined trong JavaScript: Ph\u00e2n bi\u1ec7t v\u00e0 ki\u1ec3m tra 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\/null-vs-undefined-javascript\/#Gia_tri_null_trong_JavaScript\" >Gi\u00e1 tr\u1ecb null 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\/null-vs-undefined-javascript\/#Gia_tri_undefined_trong_JavaScript\" >Gi\u00e1 tr\u1ecb undefined trong JavaScript<\/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\/null-vs-undefined-javascript\/#Kieu_du_lieu_cua_null_vs_undefiend\" >Ki\u1ec3u d\u1eef li\u1ec7u c\u1ee7a null vs undefiend<\/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\/null-vs-undefined-javascript\/#So_sanh_null_vs_undefined_trong_JavaScript\" >So s\u00e1nh null vs undefined trong JavaScript<\/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\/null-vs-undefined-javascript\/#Cach_su_dung_va_kiem_tra_null_hoac_undefined_trong_JavaScript\" >C\u00e1ch s\u1eed d\u1ee5ng v\u00e0 ki\u1ec3m tra null ho\u1eb7c undefined trong JavaScript<\/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\/null-vs-undefined-javascript\/#Cau_hoi_thuong_gap_ve_null_vs_undefined\" >C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 null vs undefined<\/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\/null-vs-undefined-javascript\/#Tong_ket\" >T\u1ed5ng k\u1ebft<\/a><\/li><\/ul><\/nav><\/div>\n\n<p><strong><em>Null vs undefined l\u00e0 c\u1eb7p gi\u00e1 tr\u1ecb d\u1ec5 g\u00e2y nh\u1ea7m l\u1eabn v\u1edbi nh\u1eefng ai m\u1edbi b\u1eaft \u0111\u1ea7u h\u1ecdc JavaScript. C\u1ea3 hai \u0111\u1ec1u \u0111\u1ea1i di\u1ec7n cho \u201ckh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb\u201d, nh\u01b0ng ch\u00fang l\u1ea1i kh\u00e1c nhau v\u1ec1 m\u1ee5c \u0111\u00edch s\u1eed d\u1ee5ng, ngu\u1ed3n g\u1ed1c v\u00e0 c\u00e1ch JavaScript x\u1eed l\u00fd ch\u00fang trong c\u00e1c ph\u00e9p to\u00e1n logic v\u00e0 so s\u00e1nh.<\/em><\/strong><\/p>\n\n\n\n<p>\u0110\u1ecdc b\u00e0i vi\u1ebft sau \u0111\u1ec3 \u0111\u01b0\u1ee3c gi\u1ea3i \u0111\u00e1p chi ti\u1ebft h\u01a1n v\u1ec1:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>T\u1ed5ng quan v\u1ec1 2 gi\u00e1 tr\u1ecb null v\u00e0 undefined trong JavaScript: \u0111\u1ecbnh ngh\u0129a, c\u00fa ph\u00e1p v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng.<\/li>\n\n\n\n<li>M\u1ed9t s\u1ed1 ki\u1ec3u (type) c\u1ee7a null v\u00e0 undefined.&nbsp;<\/li>\n\n\n\n<li>So s\u00e1nh chi ti\u1ebft gi\u1eefa null v\u1edbi undefined.<\/li>\n\n\n\n<li>Khi n\u00e0o n\u00ean s\u1eed d\u1ee5ng null ho\u1eb7c khi n\u00e0o n\u00ean s\u1eed d\u1ee5ng undefined.&nbsp;<\/li>\n\n\n\n<li>M\u1ed9t s\u1ed1 c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p li\u00ean quan v\u1ec1 null v\u1edbi undefined.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-gia-tr\u1ecb-null-trong-javascript\"><span class=\"ez-toc-section\" id=\"Gia_tri_null_trong_JavaScript\"><\/span><strong>Gi\u00e1 tr\u1ecb null trong JavaScript<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>T\u1eeb kh\u00f3a <strong>null <\/strong>bi\u1ec3u th\u1ecb m\u1ed9t gi\u00e1 tr\u1ecb v\u1eafng m\u1eb7t \u0111\u01b0\u1ee3c x\u00e1c \u0111\u1ecbnh m\u1ed9t c\u00e1ch c\u00f3 ch\u1ee7 \u00fd.&nbsp;<\/p>\n\n\n\n<p>C\u00fa ph\u00e1p:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>typeof null\n> \"object\"<\/code><\/pre>\n\n\n\n<p>null l\u00e0 m\u1ed9t ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y (primitive), m\u1eb7c d\u00f9 to\u00e1n t\u1eed typeof l\u1ea1i tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3 l\u00e0 object. \u0110\u00e2y l\u00e0 m\u1ed9t l\u1ed7i t\u1ed3n t\u1ea1i t\u1eeb phi\u00ean b\u1ea3n \u0111\u1ea7u ti\u00ean c\u1ee7a JavaScript v\u00e0 \u0111\u01b0\u1ee3c gi\u1eef nguy\u00ean cho \u0111\u1ebfn nay nh\u1eb1m tr\u00e1nh l\u00e0m gi\u00e1n \u0111o\u1ea1n h\u00e0nh vi mong \u0111\u1ee3i c\u1ee7a c\u00e1c ch\u01b0\u01a1ng tr\u00ecnh tr\u00ean web. B\u1ea1n n\u00ean l\u01b0u \u00fd r\u1eb1ng null kh\u00e1c ho\u00e0n to\u00e0n v\u1edbi \u0111\u1ed1i t\u01b0\u1ee3ng (object) \u1edf ch\u1ed7 l\u00e0 n\u00f3 kh\u00f4ng s\u1edf h\u1eefu b\u1ea5t k\u1ef3 thu\u1ed9c t\u00ednh ho\u1eb7c ph\u01b0\u01a1ng th\u1ee9c n\u00e0o, v\u00e0 kh\u00f4ng th\u1ec3 m\u1edf r\u1ed9ng th\u00eam t\u00ednh n\u0103ng.<\/p>\n\n\n\n<p>B\u1ea1n c\u00f3 th\u1ec3 khai b\u00e1o m\u1ed9t bi\u1ebfn v\u1edbi gi\u00e1 tr\u1ecb null khi mu\u1ed1n bi\u1ec3u th\u1ecb r\u1eb1ng bi\u1ebfn \u0111\u00f3 s\u1ebd \u0111\u01b0\u1ee3c g\u00e1n gi\u00e1 tr\u1ecb sau trong ch\u01b0\u01a1ng tr\u00ecnh, ho\u1eb7c \u0111\u1ec3 ch\u1ec9 r\u00f5 r\u1eb1ng gi\u00e1 tr\u1ecb \u0111ang b\u1ecb thi\u1ebfu m\u1ed9t c\u00e1ch c\u00f3 ch\u1ee7 \u0111\u00edch. B\u1ea1n c\u0169ng c\u00f3 th\u1ec3 g\u00e1n null cho m\u1ed9t tham chi\u1ebfu (reference) hi\u1ec7n c\u00f3 \u0111\u1ec3 x\u00f3a b\u1ecf gi\u00e1 tr\u1ecb tr\u01b0\u1edbc \u0111\u00f3.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-gia-tr\u1ecb-undefined-trong-javascript\"><span class=\"ez-toc-section\" id=\"Gia_tri_undefined_trong_JavaScript\"><\/span><strong>Gi\u00e1 tr\u1ecb undefined trong JavaScript<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>undefined<\/strong> l\u00e0 m\u1ed9t gi\u00e1 tr\u1ecb nguy\u00ean th\u1ee7y (primitive) \u0111\u01b0\u1ee3c g\u00e1n cho c\u00e1c bi\u1ebfn v\u1eeba \u0111\u01b0\u1ee3c khai b\u00e1o nh\u01b0ng ch\u01b0a \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o, ho\u1eb7c l\u00e0 gi\u00e1 tr\u1ecb tr\u1ea3 v\u1ec1 c\u1ee7a m\u1ed9t h\u00e0m kh\u00f4ng c\u00f3 return, ho\u1eb7c c\u00f3 return nh\u01b0ng kh\u00f4ng tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb.&nbsp;<\/p>\n\n\n\n<p>V\u00ed d\u1ee5, \u0111i\u1ec1u n\u00e0y c\u00f3 th\u1ec3 x\u1ea3y ra khi b\u1ea1n khai b\u00e1o m\u1ed9t h\u00e0m trong b\u1ea3ng \u0111i\u1ec1u khi\u1ec3n c\u1ee7a tr\u00ecnh duy\u1ec7t:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function myFunction() {}\n> undefined<\/code><\/pre>\n\n\n\n<p>M\u1ed9t h\u00e0m s\u1ebd tr\u1ea3 v\u1ec1 undefined m\u1ed9t c\u00e1ch r\u00f5 r\u00e0ng khi c\u00e2u l\u1ec7nh return kh\u00f4ng tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb n\u00e0o:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(function() {\n\u00a0\u00a0\u00a0\u00a0return;\n}());\n> undefined<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u0110\u1ecdc chi ti\u1ebft: <strong><a href=\"https:\/\/itviec.com\/blog\/javascript-undefined-la-gi\/\" target=\"_blank\" rel=\"noreferrer noopener\">Gi\u1ea3i m\u00e3 JavaScript undefined: Nguy\u00ean nh\u00e2n v\u00e0 c\u00e1ch x\u1eed l\u00fd<\/a><\/strong><\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-ki\u1ec3u-d\u1eef-li\u1ec7u-c\u1ee7a-null-vs-undefiend\"><span class=\"ez-toc-section\" id=\"Kieu_du_lieu_cua_null_vs_undefiend\"><\/span><strong>Ki\u1ec3u d\u1eef li\u1ec7u c\u1ee7a null vs undefiend<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Trong JavaScript, \u0111\u1ec3 ki\u1ec3m tra ki\u1ec3u c\u1ee7a m\u1ed9t bi\u1ebfn, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng to\u00e1n t\u1eed &#8220;typeof&#8221;.&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0110\u1ed1i v\u1edbi null, k\u1ebft qu\u1ea3 hi\u1ec3n th\u1ecb s\u1ebd l\u00e0 m\u1ed9t object.&nbsp;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var x = null;\nconsole.log(typeof(x));<\/code><\/pre>\n\n\n\n<p>\u1ede \u0111\u00e2y, b\u1ea1n \u0111\u00e3 g\u00e1n gi\u00e1 tr\u1ecb null cho bi\u1ebfn x v\u00e0 sau \u0111\u00f3 ki\u1ec3m tra ki\u1ec3u c\u1ee7a n\u00f3.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0110\u1ed1i v\u1edbi undefined, ki\u1ec3u c\u1ee7a undefined ch\u00ednh l\u00e0 undefined. V\u1ec1 c\u01a1 b\u1ea3n, \u0111\u00e2y l\u00e0 m\u1ed9t ki\u1ec3u d\u1eef li\u1ec7u ri\u00eang bi\u1ec7t.&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>V\u00ed d\u1ee5 nh\u01b0:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var x;\nconsole.log(typeof(x));<\/code><\/pre>\n\n\n\n<p>K\u1ebft qu\u1ea3 hi\u1ec3n th\u1ecb c\u1ee7a \u0111o\u1ea1n m\u00e3 tr\u00ean s\u1ebd l\u00e0 undefined. \u1ede v\u00ed d\u1ee5 tr\u00ean, \u0111\u00e3 khai b\u00e1o bi\u1ebfn x m\u00e0 kh\u00f4ng g\u00e1n gi\u00e1 tr\u1ecb n\u00e0o. Khi ch\u01b0\u01a1ng tr\u00ecnh ch\u1ea1y, gi\u00e1 tr\u1ecb undefined s\u1ebd t\u1ef1 \u0111\u1ed9ng \u0111\u01b0\u1ee3c g\u00e1n cho bi\u1ebfn x.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-so-sanh-null-vs-undefined-trong-javascript\"><span class=\"ez-toc-section\" id=\"So_sanh_null_vs_undefined_trong_JavaScript\"><\/span><strong>So s\u00e1nh null vs undefined trong JavaScript<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Vi\u1ec7c hi\u1ec3u r\u00f5 s\u1ef1 gi\u1ed1ng v\u00e0 kh\u00e1c nhau gi\u1eefa null v\u00e0 undefined kh\u00f4ng ch\u1ec9 gi\u00fap b\u1ea1n tr\u00e1nh \u0111\u01b0\u1ee3c c\u00e1c l\u1ed7i logic kh\u00f3 ph\u00e1t hi\u1ec7n, m\u00e0 c\u00f2n n\u00e2ng cao k\u1ef9 n\u0103ng vi\u1ebft m\u00e3 m\u1ed9t c\u00e1ch r\u00f5 r\u00e0ng v\u00e0 ch\u00ednh x\u00e1c h\u01a1n. D\u01b0\u1edbi \u0111\u00e2y, ITviec s\u1ebd gi\u1ea3i \u0111\u00e1p chi ti\u1ebft v\u1ec1 c\u00e1c \u0111i\u1ec3m t\u01b0\u01a1ng \u0111\u1ed3ng v\u00e0 kh\u00e1c bi\u1ec7t gi\u1eefa hai gi\u00e1 tr\u1ecb n\u00e0y.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-di\u1ec3m-gi\u1ed1ng-nhau-gi\u1eefa-null-vs-undefined\"><strong>\u0110i\u1ec3m gi\u1ed1ng nhau gi\u1eefa null vs undefined<\/strong><\/h3>\n\n\n\n<p>M\u1ed9t s\u1ed1 \u0111i\u1ec3m t\u01b0\u01a1ng \u0111\u1ed3ng gi\u1eefa null v\u00e0 undefined nh\u01b0 sau:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>C\u1ea3 hai \u0111\u1ec1u bi\u1ec3u th\u1ecb s\u1ef1 v\u1eafng m\u1eb7t c\u1ee7a gi\u00e1 tr\u1ecb.<\/li>\n\n\n\n<li>C\u1ea3 hai \u0111\u1ec1u l\u00e0 ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y (primitive) trong <a href=\"https:\/\/itviec.com\/blog\/javascript-la-gi\/\" target=\"_blank\" rel=\"noreferrer noopener\">JavaScript<\/a>, t\u1ee9c kh\u00f4ng ph\u1ea3i l\u00e0 \u0111\u1ed1i t\u01b0\u1ee3ng (object) n\u00ean kh\u00f4ng c\u00f3 ph\u01b0\u01a1ng th\u1ee9c hay thu\u1ed9c t\u00ednh n\u00e0o.<\/li>\n\n\n\n<li>C\u1ea3 hai \u0111\u1ec1u tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb false khi \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong bi\u1ec3u th\u1ee9c logic (Boolean context), t\u1ee9c l\u00e0 c\u00e1c gi\u00e1 tr\u1ecb &#8220;false&#8221;.<\/li>\n<\/ul>\n\n\n\n<p>Tuy c\u00f9ng l\u00e0 gi\u00e1 tr\u1ecb false trong JavaScript, null v\u00e0 undefined kh\u00f4ng loose equal (==) v\u1edbi b\u1ea5t k\u1ef3 gi\u00e1 tr\u1ecb false n\u00e0o kh\u00e1c nh\u01b0 s\u1ed1 0, chu\u1ed7i r\u1ed7ng (&#8220;&#8221;, &#8216; &#8216;), ho\u1eb7c NaN. Gi\u00e1 tr\u1ecb duy nh\u1ea5t m\u00e0 null \u0111\u01b0\u1ee3c loose equal l\u00e0 undefined ho\u1eb7c ch\u00ednh n\u00f3. \u0110i\u1ec1u n\u00e0y l\u00e0 do c\u01a1 ch\u1ebf \u00e9p ki\u1ec3u (type coercion) c\u1ee7a to\u00e1n t\u1eed loose equal == trong JavaScript.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var nullVar = null; \/\/ Khai b\u00e1o bi\u1ebfn nullVar v\u00e0 g\u00e1n gi\u00e1 tr\u1ecb null\nconsole.log(\"Gi\u00e1 tr\u1ecb c\u1ee7a bi\u1ebfn l\u00e0 \", nullVar); \/\/ In ra gi\u00e1 tr\u1ecb c\u1ee7a bi\u1ebfn\n\n\/\/ Ki\u1ec3m tra n\u1ebfu null b\u1eb1ng loose equal (==) v\u1edbi undefined\nif (nullVar == undefined){\n\u00a0\u00a0\u00a0\u00a0console.log(\"null loose equal v\u1edbi undefined!\");\n\n};\n\n\/\/ Ki\u1ec3m tra n\u1ebfu null loose equal v\u1edbi c\u00e1c gi\u00e1 tr\u1ecb falsy kh\u00e1c nh\u01b0 0, NaN ho\u1eb7c chu\u1ed7i r\u1ed7ng\nif(nullVar == 0 || isNaN(nullVar) || nullVar == ''){\n\u00a0\u00a0\u00a0\u00a0console.log(\"null loose equal v\u1edbi c\u00e1c gi\u00e1 tr\u1ecb falsy kh\u00e1c!\");\n}\nelse{\n\u00a0\u00a0\u00a0\u00a0console.log(\"null kh\u00f4ng loose equal v\u1edbi c\u00e1c gi\u00e1 tr\u1ecb falsy kh\u00e1c!\");\n};<\/code><\/pre>\n\n\n\n<p>K\u1ebft qu\u1ea3 khi ch\u1ea1y:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Gi\u00e1 tr\u1ecb c\u1ee7a bi\u1ebfn l\u00e0 null\n\nnull b\u1eb1ng l\u1ecfng v\u1edbi undefined!\n\nnull kh\u00f4ng b\u1eb1ng l\u1ecfng v\u1edbi c\u00e1c gi\u00e1 tr\u1ecb falsy kh\u00e1c!<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-di\u1ec3m-khac-nhau-gi\u1eefa-null-vs-undefined\"><strong>\u0110i\u1ec3m kh\u00e1c nhau gi\u1eefa null vs undefined<\/strong><\/h3>\n\n\n\n<p>D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t s\u1ed1 \u0111i\u1ec3m kh\u00e1c nhau gi\u1eefa null v\u1edbi undefined trong JavaScript<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><\/td><td><strong>undefined<\/strong><\/td><td><strong>null<\/strong><\/td><\/tr><tr><td>\u0110\u1ecbnh ngh\u0129a<\/td><td>Gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh m\u00e0 JavaScript t\u1ef1 \u0111\u1ed9ng g\u00e1n cho m\u1ed9t bi\u1ebfn \u0111\u00e3 \u0111\u01b0\u1ee3c khai b\u00e1o nh\u01b0ng ch\u01b0a \u0111\u01b0\u1ee3c g\u00e1n gi\u00e1 tr, m\u1ed9t h\u00e0m kh\u00f4ng tr\u1ea3 v\u1ec1 g\u00ec (return kh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb), ho\u1eb7c khi truy c\u1eadp m\u1ed9t property kh\u00f4ng t\u1ed3n t\u1ea1i trong object.<\/td><td>\u0110\u1ea1i di\u1ec7n cho s\u1ef1 v\u1eafng m\u1eb7t c\u00f3 ch\u1ee7 \u0111\u00edch c\u1ee7a b\u1ea5t k\u1ef3 gi\u00e1 tr\u1ecb \u0111\u1ed1i t\u01b0\u1ee3ng n\u00e0o.<\/td><\/tr><tr><td>To\u00e1n t\u1eed typeof<\/td><td>To\u00e1n t\u1eed typeof() tr\u1ea3 v\u1ec1 undefined cho bi\u1ebfn ch\u01b0a \u0111\u01b0\u1ee3c g\u00e1n gi\u00e1 tr\u1ecb. N\u1ebfu bi\u1ebfn ch\u01b0a khai b\u00e1o, typeof v\u1eabn tr\u1ea3 v\u1ec1 undefined thay v\u00ec v\u0103ng l\u1ed7i.<\/td><td>To\u00e1n t\u1eed typeof() tr\u1ea3 v\u1ec1 object cho bi\u1ebfn \u0111\u01b0\u1ee3c g\u00e1n gi\u00e1 tr\u1ecb l\u00e0 null.<\/td><\/tr><tr><td>Khi th\u1ef1c hi\u1ec7n ph\u00e9p to\u00e1n s\u1ed1 h\u1ecdc<\/td><td>Tr\u1ea3 v\u1ec1 NaN khi th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n s\u1ed1 h\u1ecdc.<\/td><td>\u0110\u01b0\u1ee3c chuy\u1ec3n th\u00e0nh 0 v\u00e0 sau \u0111\u00f3 th\u1ef1c hi\u1ec7n ph\u00e9p to\u00e1n.<\/td><\/tr><tr><td>C\u00f3 ph\u1ea3i l\u00e0 gi\u00e1 tr\u1ecb g\u00e1n kh\u00f4ng?<\/td><td>Kh\u00f4ng, v\u00ec kh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb n\u00e0o \u0111\u01b0\u1ee3c g\u00e1n cho bi\u1ebfn, n\u00ean bi\u1ebfn tr\u1edf th\u00e0nh undefined.<\/td><td>C\u00f3, v\u00ec khi ch\u00fang ta g\u00e1n null cho m\u1ed9t bi\u1ebfn, n\u00f3 l\u00e0 m\u1ed9t gi\u00e1 tr\u1ecb g\u00e1n.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u1ede ngh\u0129a ch\u00ednh x\u00e1c, null bi\u1ec3u th\u1ecb m\u1ed9t gi\u00e1 tr\u1ecb \u0111\u01b0\u1ee3c x\u00e1c \u0111\u1ecbnh m\u1ed9t c\u00e1ch c\u00f3 ch\u1ee7 \u0111\u00edch l\u00e0 &#8220;tr\u1ed1ng&#8221;, trong khi undefined bi\u1ec3u th\u1ecb vi\u1ec7c ch\u01b0a \u0111\u01b0\u1ee3c g\u00e1n b\u1ea5t k\u1ef3 gi\u00e1 tr\u1ecb n\u00e0o.<\/p>\n\n\n\n<p>null v\u00e0 undefined b\u1eb1ng nhau khi loose equal (==), nh\u01b0ng kh\u00f4ng b\u1eb1ng nhau khi so s\u00e1nh nghi\u00eam ng\u1eb7t (strictly equal) (===). To\u00e1n t\u1eed loose equal s\u1ebd th\u1ef1c hi\u1ec7n \u00e9p ki\u1ec3u hai to\u00e1n h\u1ea1ng n\u1ebfu ch\u00fang kh\u00e1c ki\u1ec3u, trong \u0111\u00f3 null ch\u1ec9 \u0111\u01b0\u1ee3c xem l\u00e0 b\u1eb1ng v\u1edbi undefined, v\u00e0 ng\u01b0\u1ee3c l\u1ea1i. Trong khi \u0111\u00f3, to\u00e1n t\u1eed so s\u00e1nh ch\u1eb7t ch\u1ebd s\u1ebd xem hai gi\u00e1 tr\u1ecb c\u00f3 ki\u1ec3u d\u1eef li\u1ec7u kh\u00e1c nhau l\u00e0 kh\u00f4ng b\u1eb1ng nhau.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>null == undefined\n> true\n\nnull === undefined\n> false<\/code><\/pre>\n\n\n\n<p>Kh\u00f4ng gi\u1ed1ng nh\u01b0 t\u1eeb kh\u00f3a d\u1ef1 tr\u1eef null, undefined l\u00e0 m\u1ed9t thu\u1ed9c t\u00ednh c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng to\u00e0n c\u1ee5c (global object). \u0110\u00e2y l\u00e0 m\u1ed9t quy\u1ebft \u0111\u1ecbnh thi\u1ebft k\u1ebf \u0111\u01b0\u1ee3c \u0111\u01b0a ra t\u1eeb r\u1ea5t s\u1edbm trong qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n JavaScript, v\u00e0 n\u00f3 \u0111\u00e3 cho ph\u00e9p c\u00e1c tr\u00ecnh duy\u1ec7t \u0111\u1eddi c\u0169 ghi \u0111\u00e8 gi\u00e1 tr\u1ecb c\u1ee7a undefined ho\u00e0n to\u00e0n.<\/p>\n\n\n\n<p>Trong c\u00e1c tr\u00ecnh duy\u1ec7t hi\u1ec7n \u0111\u1ea1i, vi\u1ec7c s\u1eed d\u1ee5ng undefined nh\u01b0 m\u1ed9t t\u00ean bi\u1ebfn (identifier) trong c\u00e1c ph\u1ea1m vi kh\u00f4ng to\u00e0n c\u1ee5c (non-global scope) v\u1eabn c\u00f3 th\u1ec3 khi\u1ebfn gi\u00e1 tr\u1ecb c\u1ee7a undefined b\u1ecb ghi \u0111\u00e8 trong ph\u1ea1m vi khai b\u00e1o \u0111\u00f3.<\/p>\n\n\n\n<p>Ngo\u00e0i ra, b\u1ea1n c\u1ea7n l\u01b0u \u00fd kh\u00f4ng bao gi\u1edd s\u1eed d\u1ee5ng undefined l\u00e0m t\u00ean bi\u1ebfn. Vi\u1ec7c n\u00e0y c\u00f3 th\u1ec3 g\u00e2y ra h\u00e0nh vi kh\u00f4ng mong mu\u1ed1n v\u00e0 d\u1ec5 g\u00e2y nh\u1ea7m l\u1eabn cho nh\u1eefng ng\u01b0\u1eddi kh\u00e1c \u0111\u1ecdc ho\u1eb7c b\u1ea3o tr\u00ec m\u00e3 c\u1ee7a b\u1ea1n sau n\u00e0y.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-vi-d\u1ee5\"><strong>V\u00ed d\u1ee5<\/strong><\/h3>\n\n\n\n<p>\u0110\u1ec3 hi\u1ec3u r\u00f5 h\u01a1n v\u1ec1 s\u1ef1 kh\u00e1c nhau gi\u1eefa null v\u1edbi undefined, b\u1ea1n c\u00f3 th\u1ec3 tham kh\u1ea3o qua v\u00ed d\u1ee5 d\u01b0\u1edbi \u0111\u00e2y:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var exp = null;\nvar base = 2;\nconsole.log(base ** exp); \/\/ 2 m\u0169 0 = 1<\/code><\/pre>\n\n\n\n<p>K\u1ebft qu\u1ea3 hi\u1ec3n th\u1ecb s\u1ebd l\u00e0 1.<\/p>\n\n\n\n<p>Nh\u01b0 \u0111\u00e3 bi\u1ebft, khi m\u1ed9t bi\u1ebfn \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o v\u1edbi gi\u00e1 tr\u1ecb null v\u00e0 th\u1ef1c hi\u1ec7n ph\u00e9p to\u00e1n s\u1ed1 h\u1ecdc tr\u00ean \u0111\u00f3, null s\u1ebd \u0111\u01b0\u1ee3c chuy\u1ec3n th\u00e0nh 0. Trong v\u00ed d\u1ee5 n\u00e0y, t\u00ednh l\u0169y th\u1eeba c\u1ee7a base, v\u1edbi s\u1ed1 m\u0169 (exp) l\u00e0 0 n\u00ean k\u1ebft qu\u1ea3 l\u00e0 1.<\/p>\n\n\n\n<p>V\u00ed d\u1ee5 2:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function areaFunction(l, b, h) {\n\u00a0\u00a0\u00a0\u00a0var area = l * b * h;\n\u00a0\u00a0\u00a0\u00a0console.log(area); \/\/ NaN\u00a0\n\u00a0\u00a0\u00a0\u00a0console.log(h);\u00a0 \u00a0 \/\/ undefined\n}\nareaFunction(19, 78);<\/code><\/pre>\n\n\n\n<p>K\u1ebft qu\u1ea3:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>NaN\n\nUndefined<\/code><\/pre>\n\n\n\n<p>B\u1edfi v\u00ec kh\u00f4ng truy\u1ec1n \u0111\u1ed1i s\u1ed1 cho bi\u1ebfn h, n\u00ean gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh c\u1ee7a n\u00f3 l\u00e0 undefined. Khi th\u1ef1c hi\u1ec7n ph\u00e9p to\u00e1n s\u1ed1 h\u1ecdc v\u1edbi m\u1ed9t bi\u1ebfn c\u00f3 gi\u00e1 tr\u1ecb undefined, k\u1ebft qu\u1ea3 s\u1ebd l\u00e0 NaN (Not a Number).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cach-s\u1eed-d\u1ee5ng-va-ki\u1ec3m-tra-null-ho\u1eb7c-undefined-trong-javascript\"><span class=\"ez-toc-section\" id=\"Cach_su_dung_va_kiem_tra_null_hoac_undefined_trong_JavaScript\"><\/span><strong>C\u00e1ch s\u1eed d\u1ee5ng v\u00e0 ki\u1ec3m tra null ho\u1eb7c undefined trong JavaScript<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-khi-nao-nen-dung-null-ho\u1eb7c-undefined\"><strong>Khi n\u00e0o n\u00ean d\u00f9ng null ho\u1eb7c undefined?<\/strong><\/h3>\n\n\n\n<p>V\u00ec undefined l\u00e0 gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh \u0111\u01b0\u1ee3c JavaScript g\u00e1n cho c\u00e1c bi\u1ebfn ch\u01b0a \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o, n\u1ebfu b\u1ea1n mu\u1ed1n ch\u1ec9 r\u00f5 r\u1eb1ng kh\u00f4ng c\u00f3 m\u1ed9t &#8220;gi\u00e1 tr\u1ecb giao d\u1ecbch&#8221; (deal) n\u00e0o, n\u00ean s\u1eed d\u1ee5ng null v\u00ec undefined v\u1eabn l\u00e0 gi\u00e1 tr\u1ecb h\u1ee3p l\u1ec7 trong m\u1ed9t s\u1ed1 API ho\u1eb7c m\u1eb7c \u0111\u1ecbnh JS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-cach-ki\u1ec3m-tra-bi\u1ebfn-co-ph\u1ea3i-la-null-ho\u1eb7c-undefined\"><strong>C\u00e1ch ki\u1ec3m tra bi\u1ebfn c\u00f3 ph\u1ea3i l\u00e0 null ho\u1eb7c undefined<\/strong><\/h3>\n\n\n\n<p>\u0110\u1ec3 ki\u1ec3m tra xem m\u1ed9t bi\u1ebfn c\u00f3 gi\u00e1 tr\u1ecb hay kh\u00f4ng tr\u01b0\u1edbc khi ti\u1ebfp t\u1ee5c th\u1ef1c hi\u1ec7n ch\u01b0\u01a1ng tr\u00ecnh, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng loose equa == null \u0111\u1ec3 ki\u1ec3m tra xem bi\u1ebfn \u0111\u00f3 c\u00f3 l\u00e0 null ho\u1eb7c undefined hay kh\u00f4ng.&nbsp;<\/p>\n\n\n\n<p>V\u00ed d\u1ee5, trong \u0111o\u1ea1n m\u00e3 sau, h\u00e0m assignVal() s\u1ebd ki\u1ec3m tra xem bi\u1ebfn num c\u00f3 \u0111ang l\u00e0 undefined ho\u1eb7c null kh\u00f4ng, v\u00e0 ch\u1ec9 g\u00e1n gi\u00e1 tr\u1ecb ng\u01b0\u1eddi d\u00f9ng \u0111\u01b0a v\u00e0o n\u1ebfu bi\u1ebfn num ch\u01b0a \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o. Do \u0111\u00f3, gi\u00e1 tr\u1ecb trong bi\u1ebfn c s\u1ebd kh\u00f4ng b\u1ecb thay \u0111\u1ed5i b\u1edfi h\u00e0m n\u00e0y:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>let assignVal = (num,val) => {\n\u00a0\u00a0\/\/ n\u1ebfu num l\u00e0 null ho\u1eb7c undefined, g\u00e1n gi\u00e1 tr\u1ecb m\u1edbi\n\u00a0\u00a0\/\/ n\u1ebfu kh\u00f4ng, gi\u1eef nguy\u00ean gi\u00e1 tr\u1ecb c\u0169\n\u00a0\u00a0if( num == null){\n\u00a0\u00a0\u00a0\u00a0num = val;\n\u00a0\u00a0}\n\u00a0\u00a0return num;\n};\nvar a;\nvar b = null;\nvar c = 0;\na = assignVal(a,100);\nb = assignVal(b,50);\nc = assignVal(c,80);\nconsole.log(\"a =\", a,\",b =\",b,\",c=\",c);\n\n\/* K\u1ebft qu\u1ea3:\n\na = 100 ,b = 50 ,c = 0\n\n*\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-tranh-l\u1ed7i-khi-bi\u1ebfn-ch\u01b0a-d\u01b0\u1ee3c-khai-bao\"><strong>Tr\u00e1nh l\u1ed7i khi bi\u1ebfn ch\u01b0a \u0111\u01b0\u1ee3c khai b\u00e1o<\/strong><\/h3>\n\n\n\n<p>N\u1ebfu b\u1ea1n c\u1ed1 g\u1eafng ki\u1ec3m tra s\u1ef1 v\u1eafng m\u1eb7t c\u1ee7a m\u1ed9t gi\u00e1 tr\u1ecb m\u00e0 bi\u1ebfn \u0111\u00f3 ch\u01b0a t\u1eebng \u0111\u01b0\u1ee3c khai b\u00e1o b\u1eb1ng ph\u01b0\u01a1ng ph\u00e1p tr\u00ean, ch\u01b0\u01a1ng tr\u00ecnh s\u1ebd n\u00e9m ra l\u1ed7i ReferenceError. Trong nh\u1eefng tr\u01b0\u1eddng h\u1ee3p nh\u01b0 v\u1eady, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng h\u00e0m typeof() \u0111\u1ec3 ki\u1ec3m tra xem bi\u1ebfn c\u00f3 \u0111\u01b0\u1ee3c khai b\u00e1o v\u00e0 kh\u1edfi t\u1ea1o \u0111\u00fang c\u00e1ch hay ch\u01b0a b\u1eb1ng c\u00e2u l\u1ec7nh sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>typeof(undeclaredVar) !== \"undefined\" &amp;&amp; undeclaredVar != null<\/code><\/pre>\n\n\n\n<p>Bi\u1ec3u th\u1ee9c n\u00e0y s\u1ebd tr\u1ea3 v\u1ec1 false n\u1ebfu bi\u1ebfn undeclaredVar:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ch\u01b0a \u0111\u01b0\u1ee3c khai b\u00e1o.<\/li>\n\n\n\n<li>\u0110\u01b0\u1ee3c khai b\u00e1o nh\u01b0ng ch\u01b0a kh\u1edfi t\u1ea1o (undefined).<\/li>\n\n\n\n<li>\u0110\u01b0\u1ee3c khai b\u00e1o nh\u01b0ng \u0111\u01b0\u1ee3c g\u00e1n l\u00e0 null ho\u1eb7c undefined.<\/li>\n<\/ul>\n\n\n\n<p>V\u00ec v\u1eady, b\u1ea1n c\u00f3 th\u1ec3 k\u1ebft lu\u1eadn r\u1eb1ng m\u1ed9t bi\u1ebfn \u0111\u00e3 \u0111\u01b0\u1ee3c khai b\u00e1o \u0111\u00fang c\u00e1ch v\u00e0 c\u00f3 gi\u00e1 tr\u1ecb h\u1ee3p l\u1ec7 khi bi\u1ec3u th\u1ee9c tr\u00ean tr\u1ea3 v\u1ec1 true.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cau-h\u1ecfi-th\u01b0\u1eddng-g\u1eb7p-v\u1ec1-null-vs-undefined\"><span class=\"ez-toc-section\" id=\"Cau_hoi_thuong_gap_ve_null_vs_undefined\"><\/span><strong>C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 null vs undefined<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-t\u1ea1i-sao-null-d\u01b0\u1ee3c-xem-la-m\u1ed9t-ki\u1ec3u-object-trong-javascript\"><strong>T\u1ea1i sao null \u0111\u01b0\u1ee3c xem l\u00e0 m\u1ed9t ki\u1ec3u Object trong JavaScript?<\/strong><\/h3>\n\n\n\n<p>Trong JavaScript, khi ki\u1ec3m tra ki\u1ec3u d\u1eef li\u1ec7u c\u1ee7a null b\u1eb1ng typeof, k\u1ebft qu\u1ea3 tr\u1ea3 v\u1ec1 l\u00e0 &#8220;object&#8221;:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>console.log(typeof null); \/\/ \"object\"<\/code><\/pre>\n\n\n\n<p>\u0110i\u1ec1u n\u00e0y l\u00e0 m\u1ed9t bug c\u1ee7a JavaScript. Khi JavaScript \u0111\u01b0\u1ee3c ph\u00e1t tri\u1ec3n l\u1ea7n \u0111\u1ea7u v\u00e0o n\u0103m 1995, c\u00e1c gi\u00e1 tr\u1ecb trong ng\u00f4n ng\u1eef n\u00e0y \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef d\u01b0\u1edbi d\u1ea1ng tagged types, trong \u0111\u00f3 m\u1ed9t ph\u1ea7n c\u1ee7a gi\u00e1 tr\u1ecb nh\u1ecb ph\u00e2n s\u1ebd ch\u1ec9 \u0111\u1ecbnh ki\u1ec3u d\u1eef li\u1ec7u.<\/p>\n\n\n\n<p>C\u1ee5 th\u1ec3, null \u0111\u01b0\u1ee3c bi\u1ec3u di\u1ec5n b\u1eb1ng bit gi\u1ed1ng nh\u01b0 c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng (object), do \u0111\u00f3 typeof null tr\u1ea3 v\u1ec1 &#8220;object&#8221;. D\u00f9 \u0111\u00e2y l\u00e0 m\u1ed9t sai s\u00f3t, n\u00f3 \u0111\u00e3 t\u1ed3n t\u1ea1i qu\u00e1 l\u00e2u n\u00ean kh\u00f4ng th\u1ec3 thay \u0111\u1ed5i m\u00e0 kh\u00f4ng ph\u00e1 v\u1ee1 c\u00e1c ch\u01b0\u01a1ng tr\u00ecnh JavaScript c\u0169.<\/p>\n\n\n\n<p>D\u00f9 <code>typeof null === \"object\"<\/code>, nh\u01b0ng null kh\u00f4ng th\u1ef1c s\u1ef1 l\u00e0 m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng, m\u00e0 l\u00e0 m\u1ed9t gi\u00e1 tr\u1ecb nguy\u00ean th\u1ee7y (primitive value) \u0111\u1ea1i di\u1ec7n cho \u201ckh\u00f4ng c\u00f3 g\u00ec\u201d.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-t\u1ea1i-sao-bi\u1ec3u-th\u1ee9c-null-undefined-l\u1ea1i-tr\u1ea3-v\u1ec1-true\"><strong>T\u1ea1i sao bi\u1ec3u th\u1ee9c null == undefined l\u1ea1i tr\u1ea3 v\u1ec1 true?<\/strong><\/h3>\n\n\n\n<p>Trong JavaScript, khi s\u1eed d\u1ee5ng to\u00e1n t\u1eed loose equality (==), tr\u00ecnh th\u00f4ng d\u1ecbch s\u1ebd t\u1ef1 \u0111\u1ed9ng chuy\u1ec3n \u0111\u1ed5i (type coercion) c\u00e1c gi\u00e1 tr\u1ecb kh\u00e1c ki\u1ec3u \u0111\u1ec3 th\u1ef1c hi\u1ec7n so s\u00e1nh.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>console.log(null == undefined); \/\/ true<\/code><\/pre>\n\n\n\n<p>C\u1ee5 th\u1ec3, theo chu\u1ea9n ECMAScript, null v\u00e0 undefined \u0111\u01b0\u1ee3c coi l\u00e0 b\u1eb1ng nhau (equal) khi d\u00f9ng ==, v\u00ec c\u1ea3 hai \u0111\u1ec1u \u0111\u1ea1i di\u1ec7n cho gi\u00e1 tr\u1ecb \u201ckh\u00f4ng x\u00e1c \u0111\u1ecbnh\u201d ho\u1eb7c \u201ckh\u00f4ng t\u1ed3n t\u1ea1i\u201d.<\/p>\n\n\n\n<p>Tuy nhi\u00ean, n\u1ebfu d\u00f9ng to\u00e1n t\u1eed so s\u00e1nh (===), th\u00ec:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>console.log(null === undefined); \/\/ false<\/code><\/pre>\n\n\n\n<p>V\u00ec l\u00fac n\u00e0y, tr\u00ecnh th\u00f4ng d\u1ecbch kh\u00f4ng th\u1ef1c hi\u1ec7n \u00e9p ki\u1ec3u, v\u00e0 do null l\u00e0 ki\u1ec3u null, c\u00f2n undefined l\u00e0 ki\u1ec3u undefined, n\u00ean ch\u00fang kh\u00f4ng b\u1eb1ng nhau.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-bi\u1ebfn-d\u01b0\u1ee3c-gan-gia-tr\u1ecb-null-co-ph\u1ea3i-la-bi\u1ebfn-ch\u01b0a-d\u01b0\u1ee3c-kh\u1edfi-t\u1ea1o-khong\"><strong>Bi\u1ebfn \u0111\u01b0\u1ee3c g\u00e1n gi\u00e1 tr\u1ecb null c\u00f3 ph\u1ea3i l\u00e0 bi\u1ebfn ch\u01b0a \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o kh\u00f4ng?<\/strong><\/h3>\n\n\n\n<p><strong>Kh\u00f4ng, bi\u1ebfn \u0111\u01b0\u1ee3c g\u00e1n gi\u00e1 tr\u1ecb null kh\u00f4ng ph\u1ea3i l\u00e0 bi\u1ebfn ch\u01b0a \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o<\/strong>. Khi b\u1ea1n g\u00e1n null cho m\u1ed9t bi\u1ebfn, \u0111i\u1ec1u \u0111\u00f3 c\u00f3 ngh\u0129a l\u00e0 b\u1ea1n \u0111\u00e3 ch\u1ee7 \u0111\u1ed9ng kh\u1edfi t\u1ea1o bi\u1ebfn \u0111\u00f3 v\u1edbi gi\u00e1 tr\u1ecb &#8220;tr\u1ed1ng&#8221;, th\u01b0\u1eddng nh\u1eb1m m\u1ee5c \u0111\u00edch r\u00f5 r\u00e0ng l\u00e0 bi\u1ebfn n\u00e0y hi\u1ec7n t\u1ea1i kh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb, nh\u01b0ng s\u1ebd \u0111\u01b0\u1ee3c g\u00e1n sau.<\/p>\n\n\n\n<p>Ng\u01b0\u1ee3c l\u1ea1i, undefined th\u01b0\u1eddng x\u1ea3y ra khi:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Bi\u1ebfn \u0111\u01b0\u1ee3c khai b\u00e1o nh\u01b0ng ch\u01b0a \u0111\u01b0\u1ee3c g\u00e1n gi\u00e1 tr\u1ecb.<\/li>\n\n\n\n<li>Tham s\u1ed1 kh\u00f4ng \u0111\u01b0\u1ee3c truy\u1ec1n v\u00e0o khi g\u1ecdi h\u00e0m.<\/li>\n\n\n\n<li>H\u00e0m kh\u00f4ng c\u00f3 return, ho\u1eb7c return kh\u00f4ng tr\u1ea3 v\u1ec1 g\u00ec.<\/li>\n\n\n\n<li>Truy c\u1eadp v\u00e0o m\u1ed9t thu\u1ed9c t\u00ednh kh\u00f4ng t\u1ed3n t\u1ea1i c\u1ee7a m\u1ed9t object.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-co-th\u1ec3-ghi-de-undefined-ho\u1eb7c-null-khong\"><strong>C\u00f3 th\u1ec3 ghi \u0111\u00e8 undefined ho\u1eb7c null kh\u00f4ng?<\/strong><\/h3>\n\n\n\n<p>V\u1edbi null, b\u1ea1n ho\u00e0n to\u00e0n c\u00f3 th\u1ec3 g\u00e1n l\u1ea1i gi\u00e1 tr\u1ecb n\u00e0y cho b\u1ea5t k\u1ef3 bi\u1ebfn n\u00e0o nh\u01b0 m\u1ed9t gi\u00e1 tr\u1ecb th\u00f4ng th\u01b0\u1eddng, v\u00ec null l\u00e0 m\u1ed9t h\u1eb1ng s\u1ed1 to\u00e0n c\u1ee5c ch\u1ee9 kh\u00f4ng ph\u1ea3i t\u1eeb kh\u00f3a b\u1ecb kh\u00f3a. Tuy nhi\u00ean, b\u1ea1n kh\u00f4ng th\u1ec3 thay \u0111\u1ed5i ch\u00ednh b\u1ea3n th\u00e2n null nh\u01b0 m\u1ed9t bi\u1ebfn, v\u00ec n\u00f3 l\u00e0 t\u1eeb kh\u00f3a c\u00f3 \u00fd ngh\u0129a \u0111\u1eb7c bi\u1ec7t trong JavaScript.<\/p>\n\n\n\n<p>V\u1edbi undefined, t\u00ecnh hu\u1ed1ng ph\u1ee9c t\u1ea1p h\u01a1n:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Trong ES3 v\u00e0 c\u00e1c phi\u00ean b\u1ea3n c\u0169, undefined c\u00f3 th\u1ec3 b\u1ecb ghi \u0111\u00e8 v\u00ec n\u00f3 ch\u1ec9 l\u00e0 m\u1ed9t bi\u1ebfn to\u00e0n c\u1ee5c kh\u00f4ng b\u1ecb b\u1ea3o v\u1ec7.<\/li>\n\n\n\n<li>T\u1eeb ES5 tr\u1edf \u0111i, undefined \u0111\u00e3 tr\u1edf th\u00e0nh read-only, n\u00ean b\u1ea1n kh\u00f4ng th\u1ec3 ghi \u0111\u00e8 gi\u00e1 tr\u1ecb n\u00e0y m\u1ed9t c\u00e1ch b\u00ecnh th\u01b0\u1eddng.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-t\u1ed5ng-k\u1ebft\"><span class=\"ez-toc-section\" id=\"Tong_ket\"><\/span><strong>T\u1ed5ng k\u1ebft<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>Null vs undefined<\/strong> tuy gi\u1ed1ng nhau \u1edf ch\u1ed7 \u0111\u1ea1i di\u1ec7n cho gi\u00e1 tr\u1ecb \u201ctr\u1ed1ng\u201d trong JavaScript, nh\u01b0ng l\u1ea1i kh\u00e1c nhau v\u1ec1 \u00fd ngh\u0129a v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng. undefined th\u01b0\u1eddng xu\u1ea5t hi\u1ec7n khi m\u1ed9t bi\u1ebfn \u0111\u01b0\u1ee3c khai b\u00e1o nh\u01b0ng ch\u01b0a g\u00e1n gi\u00e1 tr\u1ecb, trong khi null \u0111\u01b0\u1ee3c l\u1eadp tr\u00ecnh vi\u00ean g\u00e1n \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh r\u00f5 r\u00e0ng r\u1eb1ng bi\u1ebfn \u0111\u00f3 \u201ckh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb\u201d. Vi\u1ec7c ph\u00e2n bi\u1ec7t ch\u00ednh x\u00e1c s\u1ebd gi\u00fap b\u1ea1n ki\u1ec3m so\u00e1t t\u1ed1t h\u01a1n logic ch\u01b0\u01a1ng tr\u00ecnh v\u00e0 h\u1ea1n ch\u1ebf bug trong qu\u00e1 tr\u00ecnh ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Null vs undefined l\u00e0 c\u1eb7p gi\u00e1 tr\u1ecb d\u1ec5 g\u00e2y nh\u1ea7m l\u1eabn v\u1edbi nh\u1eefng ai m\u1edbi b\u1eaft \u0111\u1ea7u h\u1ecdc JavaScript. C\u1ea3 hai \u0111\u1ec1u \u0111\u1ea1i di\u1ec7n cho \u201ckh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb\u201d, nh\u01b0ng ch\u00fang l\u1ea1i kh\u00e1c nhau v\u1ec1 m\u1ee5c \u0111\u00edch s\u1eed d\u1ee5ng, ngu\u1ed3n g\u1ed1c v\u00e0 c\u00e1ch JavaScript x\u1eed l\u00fd ch\u00fang trong c\u00e1c ph\u00e9p to\u00e1n logic v\u00e0 so s\u00e1nh. [&hellip;]<\/p>\n","protected":false},"author":207,"featured_media":90880,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109,10344],"tags":[],"class_list":["post-90106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it","category-javascript"],"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>Null vs undefined trong JavaScript: Ph\u00e2n bi\u1ec7t v\u00e0 ki\u1ec3m tra chi ti\u1ebft - ITviec Blog<\/title>\n<meta name=\"description\" content=\"Null vs undefined l\u00e0 hai gi\u00e1 tr\u1ecb kh\u00e1c nhau trong JavaScript. Hi\u1ec3u r\u00f5 s\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa hai gi\u00e1 tr\u1ecb n\u00e0y \u0111\u1ec3 tr\u00e1nh l\u1ed7i v\u00e0 vi\u1ebft m\u00e3 t\u1ed1i \u01b0u h\u01a1n.\" \/>\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\/null-vs-undefined-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Null vs undefined trong JavaScript: Ph\u00e2n bi\u1ec7t v\u00e0 ki\u1ec3m tra chi ti\u1ebft\" \/>\n<meta property=\"og:description\" content=\"Null vs undefined l\u00e0 c\u1eb7p gi\u00e1 tr\u1ecb d\u1ec5 g\u00e2y nh\u1ea7m l\u1eabn v\u1edbi nh\u1eefng ai m\u1edbi b\u1eaft \u0111\u1ea7u h\u1ecdc JavaScript. C\u1ea3 hai \u0111\u1ec1u \u0111\u1ea1i di\u1ec7n cho \u201ckh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb\u201d, nh\u01b0ng ch\u00fang l\u1ea1i kh\u00e1c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/null-vs-undefined-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=\"2025-09-01T11:25:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-01T11:25:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/09\/null-vs-undefined-javascript-scaled.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1347\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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=\"13 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Null vs undefined trong JavaScript: Ph\u00e2n bi\u1ec7t v\u00e0 ki\u1ec3m tra chi ti\u1ebft - ITviec Blog","description":"Null vs undefined l\u00e0 hai gi\u00e1 tr\u1ecb kh\u00e1c nhau trong JavaScript. Hi\u1ec3u r\u00f5 s\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa hai gi\u00e1 tr\u1ecb n\u00e0y \u0111\u1ec3 tr\u00e1nh l\u1ed7i v\u00e0 vi\u1ebft m\u00e3 t\u1ed1i \u01b0u h\u01a1n.","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\/null-vs-undefined-javascript\/","og_locale":"vi_VN","og_type":"article","og_title":"Null vs undefined trong JavaScript: Ph\u00e2n bi\u1ec7t v\u00e0 ki\u1ec3m tra chi ti\u1ebft","og_description":"Null vs undefined l\u00e0 c\u1eb7p gi\u00e1 tr\u1ecb d\u1ec5 g\u00e2y nh\u1ea7m l\u1eabn v\u1edbi nh\u1eefng ai m\u1edbi b\u1eaft \u0111\u1ea7u h\u1ecdc JavaScript. C\u1ea3 hai \u0111\u1ec1u \u0111\u1ea1i di\u1ec7n cho \u201ckh\u00f4ng c\u00f3 gi\u00e1 tr\u1ecb\u201d, nh\u01b0ng ch\u00fang l\u1ea1i kh\u00e1c","og_url":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2025-09-01T11:25:57+00:00","article_modified_time":"2025-09-01T11:25:59+00:00","og_image":[{"width":2560,"height":1347,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/09\/null-vs-undefined-javascript-scaled.png","type":"image\/png"}],"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":"13 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/"},"author":{"name":"Uyen Ngo","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/f4cd1226846e0258c664e170d3e52d20"},"headline":"Null vs undefined trong JavaScript: Ph\u00e2n bi\u1ec7t v\u00e0 ki\u1ec3m tra chi ti\u1ebft","datePublished":"2025-09-01T11:25:57+00:00","dateModified":"2025-09-01T11:25:59+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/"},"wordCount":3171,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/09\/null-vs-undefined-javascript-scaled.png","articleSection":["Chuy\u00ean m\u00f4n IT","JavaScript"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/","url":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/","name":"Null vs undefined trong JavaScript: Ph\u00e2n bi\u1ec7t v\u00e0 ki\u1ec3m tra chi ti\u1ebft - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/09\/null-vs-undefined-javascript-scaled.png","datePublished":"2025-09-01T11:25:57+00:00","dateModified":"2025-09-01T11:25:59+00:00","description":"Null vs undefined l\u00e0 hai gi\u00e1 tr\u1ecb kh\u00e1c nhau trong JavaScript. Hi\u1ec3u r\u00f5 s\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa hai gi\u00e1 tr\u1ecb n\u00e0y \u0111\u1ec3 tr\u00e1nh l\u1ed7i v\u00e0 vi\u1ebft m\u00e3 t\u1ed1i \u01b0u h\u01a1n.","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/null-vs-undefined-javascript\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/09\/null-vs-undefined-javascript-scaled.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/09\/null-vs-undefined-javascript-scaled.png","width":800,"height":421,"caption":"null vs undefined javascript - itviec blog"},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/null-vs-undefined-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":"Null vs undefined trong JavaScript: Ph\u00e2n bi\u1ec7t v\u00e0 ki\u1ec3m tra 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\/90106","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=90106"}],"version-history":[{"count":3,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/90106\/revisions"}],"predecessor-version":[{"id":90881,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/90106\/revisions\/90881"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/90880"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=90106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=90106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=90106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}