{"id":3588,"date":"2020-06-08T19:00:47","date_gmt":"2020-06-08T16:00:47","guid":{"rendered":"https:\/\/elzero.org\/?p=3588"},"modified":"2020-06-12T22:40:05","modified_gmt":"2020-06-12T19:40:05","slug":"dot-notation-vs-bracket-notation","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/dot-notation-vs-bracket-notation\/","title":{"rendered":"Dot Notation vs Bracket Notation"},"content":{"rendered":"<h3>\u0627\u0644 Code \u0627\u0644\u0645\u0648\u062c\u0648\u062f \u0641\u064a \u0627\u0644\u062f\u0631\u0633<\/h3>\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\nlet myObj = {\r\n  \"One\": 1,\r\n  \"Two!\": 2\r\n};\r\n\r\nconsole.log(myObj.One);\r\n\/\/ console.log(myObj.\"One\"); \/\/ Syntax Error\r\n\/\/ console.log(myObj.Two!); \/\/ Syntax Error\r\n\r\nconsole.log(myObj[\"One\"]); \/\/ 1\r\nconsole.log(myObj[\"Two!\"]); \/\/ 2\r\n\r\nlet myObj2 = {\r\n  1: \"One\",\r\n  2: \"Two\"\r\n};\r\n\r\n\/\/ console.log(myObj2.1); \/\/ Syntax Error\r\n\r\nconsole.log(myObj2[\"1\"]);\r\nconsole.log(myObj2[\"2\"]);\r\n\r\nlet myVariable = \"name\";\r\n\r\nlet myLastObj = {\r\n  name: \"Osama\"\r\n};\r\n\r\nconsole.log(myLastObj.myVariable); \/\/ Undefined\r\nconsole.log(myLastObj[myVariable]); \/\/ Osama\r\nconsole.log(myLastObj[\"name\"]); \/\/ Osama\r\n<\/script>\r\n<hr>\r\n<h3>\u0645\u0644\u0627\u062d\u0638\u0627\u062a \u0627\u0644\u062f\u0631\u0633<\/h3>\r\n\u0644\u0627 \u062a\u0648\u062c\u062f \u0645\u0644\u0627\u062d\u0638\u0627\u062a \u062d\u0627\u0644\u064a\u0627","protected":false},"excerpt":{"rendered":"<p>\u0627\u0644 Code \u0627\u0644\u0645\u0648\u062c\u0648\u062f \u0641\u064a \u0627\u0644\u062f\u0631\u0633 \u0645\u0644\u0627\u062d\u0638\u0627\u062a \u0627\u0644\u062f\u0631\u0633 \u0644\u0627 \u062a\u0648\u062c\u062f \u0645\u0644\u0627\u062d\u0638\u0627\u062a \u062d\u0627\u0644\u064a\u0627<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[436],"tags":[],"class_list":["post-3588","post","type-post","status-publish","format-standard","hentry","category-javascript-oop"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/3588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=3588"}],"version-history":[{"count":2,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/3588\/revisions"}],"predecessor-version":[{"id":3771,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/3588\/revisions\/3771"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=3588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=3588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=3588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}