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


Groups > comp.lang.javascript > #36905

Re: Object prop missing?

Path csiph.com!3.eu.feeder.erje.net!feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Object prop missing?
Date Thu, 13 Jun 2019 17:30:09 +0200
Organization PointedEars Software (PES)
Lines 34
Message-ID <4513428.33T0Q7i3B6@PointedEars.de> (permalink)
References <p6KdnbVLAPPqcZzAnZ2dnUU7-QfNnZ2d@westnet.com.au> <12600445.cR47uQ6sgG@PointedEars.de> <kcidnW32l-lhgp_AnZ2dnUU7-TvNnZ2d@westnet.com.au> <XnsAA6D7FBCFA34eejj99@194.109.6.166> <4KGdnc1BE6S_tp_AnZ2dnUU7-YXNnZ2d@westnet.com.au> <2720861.OsphAzSTzx@PointedEars.de> <pKGdnVhrbtEIpJ_AnZ2dnUU7-d3NnZ2d@westnet.com.au>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace news.albasani.net HLGHQYB0C+bfXbA3B07pxbz4zxCThPExcb8LEZ878ac1C805IGiOwJK2wyy2Thax4yZfgvRRGjgVgja3viH7OswwVTu9q/yaKwqSJ85GU3yn2KQW+/xKVmN1MITMe5SA
NNTP-Posting-Date Thu, 13 Jun 2019 15:30:10 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="vQ57RVlYsqYYUw1QaFtuXhRk/bjay/pVBrIFd4TtFzi0gBK8m+p7LVbxnpl2VgX70E89rtABkmQ0+bcIOjp+hjZwthcQItiAl6nNIV+TrOyPBw3q5o0Xq5XtVMu3L9XB"; mail-complaints-to="abuse@albasani.net"
User-Agent KNode/4.14.10
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFE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4v
Cancel-Lock sha1:lGo48mqefmlTZLyn2gNeJpQHB20=
Xref csiph.com comp.lang.javascript:36905

Show key headers only | View raw


Andrew Poulos wrote:

> […] but what I can't understand is with this:
> 
>    console.log(options[1]);   // 1.
>    console.log(options[1].h); // 2.
> 
> why 1. shows a value for h yet 2. (which immediately follows 1.) says h
> is undefined.

Very simple: You have not added the property to the object referred to by 
“options[1]”, you have added it and removed it later, or you have set it to 
“undefined”.  “JJ”’s argument is sound as well.

For example, one can create an object that cannot be augmented with 
properties:

  var obj = Object.freeze({});

  /* TypeError exception only in strict mode */
  obj.h = 42;
  
  /* undefined */
  console.log(obj.h);

This behavior actually applies to primitive strings since ECMAScript Ed. 5.
[If one wishes to call custom methods on string values, one must augment the 
String prototype, or use .call() or .apply() instead.]

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

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


Thread

Object prop missing? Andrew Poulos <ap_prog@hotmail.com> - 2019-06-13 16:25 +1000
  Re: Object prop missing? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-06-13 09:37 +0200
    Re: Object prop missing? Andrew Poulos <ap_prog@hotmail.com> - 2019-06-13 20:05 +1000
      Re: Object prop missing? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-06-13 12:33 +0200
        Re: Object prop missing? Andrew Poulos <ap_prog@hotmail.com> - 2019-06-13 20:53 +1000
          Re: Object prop missing? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-06-13 13:09 +0200
            Re: Object prop missing? Andrew Poulos <ap_prog@hotmail.com> - 2019-06-13 21:54 +1000
              Re: Object prop missing? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-06-13 17:30 +0200
      Re: Object prop missing? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-06-13 13:05 +0200
  Re: Object prop missing? JJ <jj4public@vfemail.net> - 2019-06-13 15:41 +0700

csiph-web