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


Groups > comp.lang.javascript > #33963 > unrolled thread

undefined string in an object?

Started byJRough <janis.rough@gmail.com>
First post2017-09-06 16:33 -0700
Last post2017-09-23 09:02 -0700
Articles 15 — 8 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

#33963 — undefined string in an object?

FromJRough <janis.rough@gmail.com>
Date2017-09-06 16:33 -0700
Subjectundefined string in an object?
Message-ID<bb27e72b-f746-44f9-a1d5-d6c5673b9ef7@googlegroups.com>
	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,

[toc] | [next] | [standalone]


#33971

FromJoao Rodrigues <groups_jr-1@yahoo.com>
Date2017-09-09 11:07 -0300
Message-ID<op0sil$dcd$1@gioia.aioe.org>
In reply to#33963
JRough wrote:
> 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,
> 

This object literal is being defined accordingly.
var a = {};
a["b"]=123, a["c"]=456;
          ^^^

There you have used the comma operator, maybe unwittingly, but it was ok 
in this case.
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator>

console.log(a["b"]) is returning "123", and then undefined.

If you write console.log(a) or console.dir(a), you'll retrieve:
{ b: 123, c: 456 }

See also 
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors>

-- 
Joao Rodrigues

[toc] | [prev] | [next] | [standalone]


#33972

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2017-09-10 16:20 +0200
Message-ID<33454482.oW9n1slzhM@PointedEars.de>
In reply to#33971
Joao Rodrigues wrote:

> JRough wrote:
>> 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,
> 
> This object literal is being defined accordingly.

The (referred) _object_ is being defined as intended.

An object *literal* (standard term: “object _initializer_”; it is actually 
_not_ listed under “11.8 Literals”[1]) is an *expression* that begins with 
“{”, ends with “}”, and can be produced by the /ObjectLiteral/ production
of the ECMAScript grammar:

<http://www.ecma-international.org/ecma-262/8.0/#prod-ObjectLiteral>

    [Yes, *8.0*: “ECMAScript® 2017 Language Specification
     (ECMA-262, 8th edition, June 2017”.
                             ^^^^^^^^^
     Harder to keep track of this nowadays.  Given the recent releases,
     I just tried the greater revision number, and there it was.]

For example, “{}” is an object initializer; so are “{foo: "bar"}” and 
“{"baz": 42}”.

An object is a conceptual entity only: it exists only abstractly, and in 
memory only inasfar as that memory is reserved to store therein the bindings 
that refer to the object, and the names and the values of its properties.

By contrast, an object *initializer* is an element of the syntax of these 
programming languages.

<http://www.ecma-international.org/ecma-262/8.0/#sec-terms-and-definitions-object>

__________
[1] <http://www.ecma-international.org/ecma-262/8.0/#sec-ecmascript-language-lexical-grammar-literals>
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#33991

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2017-09-18 15:37 +0100
Message-ID<egmvrc9e3lf8vl7rop0lnmm1mt29lcikht@4ax.com>
In reply to#33972
On Sun, 10 Sep 2017 16:20:43 +0200, Thomas 'PointedEars' Lahn
<PointedEars@web.de> wrote:

  <snip>
>An object is a conceptual entity only: it exists only abstractly, 
  <snip>

That's a strange thing to say. All software and the constructs within
it are conceptual and abstract. Software is nothing more than a
pattern made from charge, magnetism, voltage, whatever. It is humans
who declare that that part of the pattern is a picture, that part is a
number, that part is code to tell the processor what to do, etc. And
that part is an Object.

  John

[toc] | [prev] | [next] | [standalone]


#33992

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2017-09-18 17:17 +0200
Message-ID<4323906.31r3eYUQgx@PointedEars.de>
In reply to#33991
John G Harris wrote:

> On Sun, 10 Sep 2017 16:20:43 +0200, Thomas 'PointedEars' Lahn
> <PointedEars@web.de> wrote:
>   <snip>
>>An object is a conceptual entity only: it exists only abstractly,
>   <snip>
> 
> That's a strange thing to say.  […]

Not if you read the statement *in context*.


Shaking his head,
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#33995

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2017-09-19 11:05 +0100
Message-ID<2sq1scl5ia1b5vbv8jrr28sluvjfi1b7lo@4ax.com>
In reply to#33992
On Mon, 18 Sep 2017 17:17:46 +0200, Thomas 'PointedEars' Lahn
<PointedEars@web.de> wrote:

>John G Harris wrote:
>
>> On Sun, 10 Sep 2017 16:20:43 +0200, Thomas 'PointedEars' Lahn
>> <PointedEars@web.de> wrote:
>>   <snip>
>>>An object is a conceptual entity only: it exists only abstractly,
>>   <snip>
>> 
>> That's a strange thing to say.  […]
>
>Not if you read the statement *in context*.
  <snip>

In any context it reads as though objects are a special case. That is
what was a strange thing to say.

  John

[toc] | [prev] | [next] | [standalone]


#33996

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2017-09-19 12:58 +0200
Message-ID<3348286.kQq0lBPeGt@PointedEars.de>
In reply to#33995
</killfile>

John G Harris wrote:

> On Mon, 18 Sep 2017 17:17:46 +0200, Thomas 'PointedEars' Lahn
> <PointedEars@web.de> wrote:
>>John G Harris wrote:
>>> On Sun, 10 Sep 2017 16:20:43 +0200, Thomas 'PointedEars' Lahn
>>> <PointedEars@web.de> wrote:
>>>   <snip>
>>>>An object is a conceptual entity only: it exists only abstractly,
>>>   <snip>
>>> 
>>> That's a strange thing to say.  […]
>>
>>Not if you read the statement *in context*.
>   <snip>
> 
> In any context it reads as though objects are a special case.

They *are* *in* *this* *context*.  You can *write* and *read* source code.  
You can only *think* of objects.

> That is what was a strange thing to say.

Perhaps it is my fault.  I am just not able to break my explanations down to 
your level of understanding.

Or you are just a troll, *playing* stupid.

In any case, you have proven once again that reading your postings is just a 
waste of time for me.

<killfile>

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#33999

FromFlng Fck <nothanks@invalid.invalid>
Date2017-09-20 09:37 +0200
Message-ID<opt5s2$1j9$1@dont-email.me>
In reply to#33996
Il 19/09/2017 12:58, Thomas 'PointedEars' Lahn ha scritto:
>>>>> An object is a conceptual entity only: it exists only abstractly,
>>>>    <snip>
>>>>
>>>> That's a strange thing to say.  […]
>>> Not if you read the statement *in context*.
>>    <snip>
>>
>> In any context it reads as though objects are a special case.
> They *are* *in* *this* *context*.  You can *write* and *read* source code.
> You can only *think* of objects.

Then define what "*this* *context*" is, otherwise it would be you the 
one who's just trolling along

[toc] | [prev] | [next] | [standalone]


#34000

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2017-09-20 10:49 +0100
Message-ID<88e4schu9on5co5m01nt5huomsn60leg8r@4ax.com>
In reply to#33996
On Tue, 19 Sep 2017 12:58:03 +0200, Thomas 'PointedEars' Lahn
<PointedEars@web.de> wrote:

></killfile>
>
>John G Harris wrote:
>
>> On Mon, 18 Sep 2017 17:17:46 +0200, Thomas 'PointedEars' Lahn
>> <PointedEars@web.de> wrote:
>>>John G Harris wrote:
>>>> On Sun, 10 Sep 2017 16:20:43 +0200, Thomas 'PointedEars' Lahn
>>>> <PointedEars@web.de> wrote:
>>>>   <snip>
>>>>>An object is a conceptual entity only: it exists only abstractly,
>>>>   <snip>
>>>> 
>>>> That's a strange thing to say.  [?]
>>>
>>>Not if you read the statement *in context*.
>>   <snip>
>> 
>> In any context it reads as though objects are a special case.
>
>They *are* *in* *this* *context*.  You can *write* and *read* source code.  
>You can only *think* of objects.
  <snip>

Is he really saying objects are conceptual but variables and primitive
strings aren't ?

><killfile>

Hooray! I can now say anything without snide comments appearing.

  John

[toc] | [prev] | [next] | [standalone]


#34001

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2017-09-20 20:29 +0100
Message-ID<87y3p96uf4.fsf@bsb.me.uk>
In reply to#34000
John G Harris <niam@jghnorth.org.uk.invalid> writes:

> On Tue, 19 Sep 2017 12:58:03 +0200, Thomas 'PointedEars' Lahn
> <PointedEars@web.de> wrote:
<snip>
>><killfile>
>
> Hooray! I can now say anything without snide comments appearing.

How have you managed this?  I'm seriously jealous.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#34003

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2017-09-21 16:12 +0100
Message-ID<sml7sctlgkjqih2e6kk05ag41penp675n9@4ax.com>
In reply to#34001
On Wed, 20 Sep 2017 20:29:03 +0100, Ben Bacarisse
<ben.usenet@bsb.me.uk> wrote:

>John G Harris <niam@jghnorth.org.uk.invalid> writes:
>
>> On Tue, 19 Sep 2017 12:58:03 +0200, Thomas 'PointedEars' Lahn
>> <PointedEars@web.de> wrote:
><snip>
>>><killfile>
>>
>> Hooray! I can now say anything without snide comments appearing.
>
>How have you managed this?  I'm seriously jealous.

<killfile> is your friend :-)

  John

[toc] | [prev] | [next] | [standalone]


#34004

Fromjonas.thornvall@gmail.com
Date2017-09-22 06:11 -0700
Message-ID<3038716d-f026-476d-b8e6-2634878fab72@googlegroups.com>
In reply to#33963
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?
isn't a[] supposed to be an array, i see you guys call it object here?

[toc] | [prev] | [next] | [standalone]


#34006

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2017-09-22 19:20 +0200
Message-ID<XnsA7F8C4B7FE614eejj99@194.109.6.166>
In reply to#34004
jonas.thornvall@gmail.com wrote on 22 Sep 2017 in comp.lang.javascript:

> 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; 

[..]
 
> Can you really have a string as an index?
> isn't a[] supposed to be an array, i see you guys call it object here?

An object {} and an array [] are NOT!!!!!! the same.

Why not go back to basics and study for a few .... months?



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#34008

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2017-09-23 10:55 +0100
Message-ID<urbcsc19viuqf368qkjjo42iugldst9j7h@4ax.com>
In reply to#34004
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

[toc] | [prev] | [next] | [standalone]


#34012

Fromjonas.thornvall@gmail.com
Date2017-09-23 09:02 -0700
Message-ID<c13d172e-04be-4ef7-a993-ecc7d290f8ad@googlegroups.com>
In reply to#34008
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.

 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web