{"id":1170,"date":"2023-11-20T00:00:00","date_gmt":"2023-11-20T05:00:00","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=1170"},"modified":"2023-11-29T17:19:16","modified_gmt":"2023-11-29T22:19:16","slug":"what-is-the-difference-between-and-in-javascript","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/what-is-the-difference-between-and-in-javascript\/","title":{"rendered":"What is the difference between =, ==, and === in JavaScript"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li><strong>= is for assignment<\/strong><\/li>\n\n\n\n<li><strong>== tests for equality of value and allows automatic casting<\/strong><\/li>\n\n\n\n<li><strong>=== tests for equality of type and value<\/strong><\/li>\n<\/ul>\n\n\n\n<p>The following example illustrates the difference between =, ==, and ===<\/p>\n\n\n\n<p>var x = 10 \/\/ int<br>var y = \u201c10\u201d \/\/ string<br>x == y \/\/ returns true<br>x === y \/\/ returns false<\/p>\n\n\n\n<p>x==y casts y to an integer and then compares the two values, returning true<br>x === y tests for both type and value so there is no automatic casting. Since integer 10 is not equal to string 10, the test returns false<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following example illustrates the difference between =, ==, and === var x = 10 \/\/ intvar y = \u201c10\u201d \/\/ stringx == y \/\/ returns truex === y \/\/ returns false x==y casts y to an integer and then compares the two values, returning truex === y tests for both type and value so [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1192,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[185],"tags":[397,399],"class_list":["post-1170","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-javascript-comparison-operators","tag-javascript-equality-operators"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1170","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=1170"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1170\/revisions"}],"predecessor-version":[{"id":1171,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/1170\/revisions\/1171"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media\/1192"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=1170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=1170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=1170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}