Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #34012

Re: undefined string in an object?

Newsgroups comp.lang.javascript
Date 2017-09-23 09:02 -0700
References <bb27e72b-f746-44f9-a1d5-d6c5673b9ef7@googlegroups.com> <3038716d-f026-476d-b8e6-2634878fab72@googlegroups.com> <urbcsc19viuqf368qkjjo42iugldst9j7h@4ax.com>
Message-ID <c13d172e-04be-4ef7-a993-ecc7d290f8ad@googlegroups.com> (permalink)
Subject Re: undefined string in an object?
From jonas.thornvall@gmail.com

Show all headers | View raw


Den lördag 23 september 2017 kl. 11:55:50 UTC+2 skrev John G Harris:
> On Fri, 22 Sep 2017 06:11:54 -0700 (PDT), jonas.thornvall@gmail.com
> wrote:
> 
> >Den torsdag 7 september 2017 kl. 01:33:10 UTC+2 skrev JRough:
> >> me (JRough change) 	
> >> 
> >> 4:31 PM (less than a minute ago)
> >> 
> >> 
> >> var a={}; 
> >>     a["b"]=123, 
> >>     a["c"]=456; 
> >> console.log(a["b"]); 
> >> undefined 
> >> 
> >> var a={}; 
> >>     a.b=123, 
> >>     a.c=456; 
> >> console.log(a.b); 
> >> undefined 
> >> 
> >> 
> >> Why is this object literal not defined?  If it is because it was stringified how to make it an object again so you get the value?  tnx,
> >
> >Can you really have a string as an index?
> 
> Yes.
> 
>   a["b"]=123;
> is specified by the ECMAScript Standard to mean exactly the same as
>   a.b=123;
> 
> 
> >isn't a[] supposed to be an array, i see you guys call it object here?
> 
> a is an ordinary object, but you can use array notation to select a
> property.
> 
>   John

Thanks John i think i learned something, i see what a property is.
You say that if you have a property of an object, a["b"]=123; "b" is the property and 123 is the property value?

I can reach the variable stored by  c=a["b"] and then
console.log(c);
Will write out 123?

I guess a is the object so how many properties can an object have?
Can an objects property also refer to a new object itself? 
So you can make a relational chain with objects?

That somehow would need objects possible to be created on the fly without have them defined, so it probably not possible?

var a={}; 
a[b={}]=1, 

The neat thing with arrays and indexes is that they are easily accesible, so it possible to make relational structures quite easy, i was just thinking if something similar was possible with objects.

 

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

undefined string in an object? JRough <janis.rough@gmail.com> - 2017-09-06 16:33 -0700
  Re: undefined string in an object? Joao Rodrigues <groups_jr-1@yahoo.com> - 2017-09-09 11:07 -0300
    Re: undefined string in an object? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-09-10 16:20 +0200
      Re: undefined string in an object? John G Harris <niam@jghnorth.org.uk.invalid> - 2017-09-18 15:37 +0100
        Re: undefined string in an object? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-09-18 17:17 +0200
          Re: undefined string in an object? John G Harris <niam@jghnorth.org.uk.invalid> - 2017-09-19 11:05 +0100
            Re: undefined string in an object? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-09-19 12:58 +0200
              Re: undefined string in an object? Flng Fck <nothanks@invalid.invalid> - 2017-09-20 09:37 +0200
              Re: undefined string in an object? John G Harris <niam@jghnorth.org.uk.invalid> - 2017-09-20 10:49 +0100
                Re: undefined string in an object? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-09-20 20:29 +0100
                Re: undefined string in an object? John G Harris <niam@jghnorth.org.uk.invalid> - 2017-09-21 16:12 +0100
  Re: undefined string in an object? jonas.thornvall@gmail.com - 2017-09-22 06:11 -0700
    Re: undefined string in an object? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-09-22 19:20 +0200
    Re: undefined string in an object? John G Harris <niam@jghnorth.org.uk.invalid> - 2017-09-23 10:55 +0100
      Re: undefined string in an object? jonas.thornvall@gmail.com - 2017-09-23 09:02 -0700

csiph-web