Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: object is undefined

15 views
Skip to first unread message

Andrew Poulos

unread,
Sep 6, 2017, 9:23:59 PM9/6/17
to
On 7/09/2017 9:31 AM, JRough wrote:
> 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? tnx,

Possibly because of the comma at the end of the line (instead of semi
colon).

Andrew Poulos

Andrew Poulos

unread,
Sep 6, 2017, 9:27:42 PM9/6/17
to
I posted without testing. In Chrome your code returns the correct value
so it's probably something else you're doing.

Andrew Poulos

JRough

unread,
Sep 6, 2017, 9:33:25 PM9/6/17
to
Thanks a lot. I played around iwth my console in chrome some setting was doing that. don't even know what but now it says 123. thanks,

Thomas 'PointedEars' Lahn

unread,
Sep 8, 2017, 3:21:46 AM9/8/17
to
Stefan Ram wrote:

> JRough <janis...@gmail.com> writes:
>>console.log(a["b"]);
>>undefined
>
> The value of the call »console.log(...)« usually /is/
> undefined.

The _return value of the method_ is _defined_ to be:

<https://console.spec.whatwg.org/#log>

> The actual output might not have appeared in the console this was copied
> from.

Doubtful.

> So, possibly, one just sees the value of the call.

The _return value of the method_, _definitely_.

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

Jake Jarvis

unread,
Sep 8, 2017, 4:59:30 AM9/8/17
to
Am 08.09.2017 um 09:21 schrieb Thomas 'PointedEars' Lahn:
> Stefan Ram wrote:
>> The actual output might not have appeared in the console this was copied
>> from.
>
> Doubtful.

Why? Is that a disagree-by-default?


Changing levels does that and it makes sense with

| I played around iwth my console in chrome some setting was doing
| that. don't even know what but now it says 123. thanks,

Default levels:
console.log("asdf")
VM168:1 asdf
undefined

Custom levels (like only Warnings and Errors):
console.log("asdf")
undefined

Thomas 'PointedEars' Lahn

unread,
Sep 8, 2017, 5:14:27 AM9/8/17
to
Jake Jarvis wrote:

> Am 08.09.2017 um 09:21 schrieb Thomas 'PointedEars' Lahn:
>> Stefan Ram wrote:
>>> The actual output might not have appeared in the console this was
>>> copied from.
>>
>> Doubtful.
>
> Why?

I considered the possibilities that the output may have appeared in another
console, or not at all, and found them improbable.

> Is that a disagree-by-default?

No.

> Changing levels does that and it makes sense with

ACK.

> | I played around iwth my console in chrome some setting was doing
> | that. don't even know what but now it says 123. thanks,

This had not been quoted.

> Default levels:
> console.log("asdf")
> VM168:1 asdf
> undefined
>
> Custom levels (like only Warnings and Errors):
> console.log("asdf")
> undefined

ACK. I had not thought of that.
0 new messages