{"id":1581,"date":"2011-03-26T21:38:00","date_gmt":"2011-03-26T21:38:00","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=1581"},"modified":"2011-03-26T21:42:35","modified_gmt":"2011-03-26T21:42:35","slug":"javascript","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2011\/03\/26\/javascript\/","title":{"rendered":"Javascript {} []"},"content":{"rendered":"<p>Someone asked me what is the difference between {} and [] within javascript.<\/p>\n<p>Basically the difference is one is a key => value pair like PHP &#8216;{}&#8217;, and the other is just a pure array of values &#8216;[]&#8217;.<\/p>\n<p>Here is the code.<\/p>\n<pre lang=\"java\">\r\nvar simplearray = [\"genux\",\"linux\"];\r\n\r\nvar keyvaluearray = {\"name\" : \"genux\", \"OS\" : \"linux\"};\r\n<\/pre>\n<p>To access the different values, since the simple array is index by numbers 0 onwards you use the [x] notation, and the key value array you can reference the value by the name of the key like in object orientated way.<\/p>\n<pre lang=\"java\">\r\nalert(simplearray[0]);\r\n\r\nalert(keyvaluearray.name);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Someone asked me what is the difference between {} and [] within javascript. Basically the difference is one is a key => value pair like PHP &#8216;{}&#8217;, and the other is just a pure array of values &#8216;[]&#8217;. Here is the code. var simplearray = [&#8220;genux&#8221;,&#8221;linux&#8221;]; var keyvaluearray = {&#8220;name&#8221; : &#8220;genux&#8221;, &#8220;OS&#8221; : &#8220;linux&#8221;}; &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2011\/03\/26\/javascript\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Javascript {} []<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[334],"class_list":["post-1581","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-334"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/1581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=1581"}],"version-history":[{"count":3,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/1581\/revisions"}],"predecessor-version":[{"id":1583,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/1581\/revisions\/1583"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=1581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=1581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=1581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}