{"id":790,"date":"2017-03-27T11:34:35","date_gmt":"2017-03-27T19:34:35","guid":{"rendered":"http:\/\/www.tech.dimprash.com\/?p=790"},"modified":"2017-03-27T11:40:20","modified_gmt":"2017-03-27T19:40:20","slug":"identifying-primitive-and-reference-types-in-javascript","status":"publish","type":"post","link":"http:\/\/www.tech.dimprash.com\/?p=790","title":{"rendered":"Identifying Primitive and Reference Types in Javascript"},"content":{"rendered":"<p>5 Primitive Types: Number, Boolean, String, Null, Undefined <\/p>\n<p>typeof &#8220;abc&#8221; => string<br \/>\ntypeof &#8220;true&#8221; => boolean<br \/>\ntypeof will work for mostly all of above except null.<br \/>\ntypeof null will return &#8220;object&#8221;.<br \/>\nSo to verify &#8220;null&#8221; just compare to null. (value == null)<\/p>\n<p>6 Reference Types: Function, Object, Array, Date, Error, RegExp<\/p>\n<p>typeof object will be &#8220;object&#8221;<br \/>\ntypeof function will be &#8220;function&#8221;<\/p>\n<p>for all the rest use instanceof to identity<\/p>\n<p>items instanceof Array<\/p>\n<p>Note that items instanceof Object will also return true since instanceof can identity inherited types. <\/p>\n<p>For Array, if you are using frames and communicating values between frames then instanceof may not provide accurate results if you are checking instanceof. Its recommended to use Array.isArray(items) in that case. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>5 Primitive Types: Number, Boolean, String, Null, Undefined typeof &#8220;abc&#8221; => string typeof &#8220;true&#8221; => boolean typeof will work for mostly all of above except null. typeof null will return &#8220;object&#8221;. So to verify &#8220;null&#8221; just compare to null. (value == null) 6 Reference Types: Function, Object, Array, Date, Error, RegExp typeof object will be &hellip; <a href=\"http:\/\/www.tech.dimprash.com\/?p=790\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Identifying Primitive and Reference Types in Javascript<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-790","post","type-post","status-publish","format-standard","hentry","category-javascript"],"_links":{"self":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=790"}],"version-history":[{"count":3,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/790\/revisions"}],"predecessor-version":[{"id":793,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/790\/revisions\/793"}],"wp:attachment":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=790"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}