Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: How do I access nested key/value pairs? Supersedes: <1933072.Sqv6qEQ7LK@PointedEars.de> Date: Thu, 05 Mar 2015 16:25:27 +0100 Organization: PointedEars Software (PES) Lines: 52 Message-ID: <2031858.aWiVlKuHNg@PointedEars.de> References: <3e102a71-73a4-41d5-811d-de9d0952f0cd@googlegroups.com> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1425569206 2609 eJwFwQcBACAMAzBL7DM57NS/BBITJ+9QN1eDwbkzLvgFyWxiBL3Y5dTSu++wHNYiWG9N8wcr+BHy (5 Mar 2015 15:26:46 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Thu, 5 Mar 2015 15:26:46 +0000 (UTC) User-Agent: KNode/4.14.2 Cancel-Key: sha1:5ANOvtVi5I1tmGxu3TVfJfq34As= X-User-ID: eJwNwokRwDAIA7CVKOHrOAaT/UdoT/ITT0xaeJjf3wAduIz0pcp2IR+Dq3BmF2dFwDRlkTtgA1or9Wbdzg+U2Rdf Cancel-Lock: sha1:V3vbXASHWUMyHmPXdJaIixQCvOw= X-NNTP-Posting-Host: eJwFwYEBACAEBMCViEfjqM/+I3QHC42bHgjHYBw1nTqzeaT6ksLOBvst43YJXbR6ftQVxg8zkhGF Xref: csiph.com comp.lang.javascript:26992 Denis McMahon wrote: > On Wed, 04 Mar 2015 07:51:44 -0800, Masoom Tulsiani wrote: >> var hash = > > hash seems to be an object containing three anonymous objects with no > means of distinguishing them. > > Trying to load this in javascript causes an error because each element of > an object (including a nested object) requires an identifier. Utter nonsense. - There is no “javascript”, see my sig. - Objects do not have names (so it makes no sense to speak of “anonymous objects”); they have identity (one object is different from another). - Objects do not have elements; they have properties. *Arrays* have elements; they are objects which also have indexes (special property names). - Property names do not need to be identifiers (for example, indexes are not identifiers as they are representation of integers). In implementations of ECMAScript Edition 5 and later they can even be reserved words. var x = {"1701foo": "bar"}; var u = x; /* "bar" */ u["1701foo"] x["1701foo"] = "baz"; /* "baz" */ u["1701foo"] /* true */ u == x /* true */ u === x /* ES 5+ only */ x.float = Math.PI; /* 3.141592653589793… */ u.float -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.