Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30590
| Path | csiph.com!feeder.erje.net!1.eu.feeder.erje.net!news.albasani.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: not "autovivification", but ...? |
| Date | Tue, 31 May 2016 17:31:36 +0200 |
| Organization | PointedEars Software (PES) |
| Lines | 39 |
| Message-ID | <1570701.170j4HGxR2@PointedEars.de> (permalink) |
| References | <autovivification-20160531121607@ram.dialup.fu-berlin.de> |
| 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 | solani.org 1464708696 14493 eJwNyckBgAAIA7CZuFocBxD2H0HzTRgEQ0fA4+Iyc0wekidV062hPsVzUO+fNWpj88XKin4UyxDe (31 May 2016 15:31:36 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Tue, 31 May 2016 15:31:36 +0000 (UTC) |
| User-Agent | KNode/4.14.2 |
| X-User-ID | eJwNx8kBwDAIA7CVwmFDxykE9h+h1U8wCjucoGOxdmCrt6AI95uznU++p95me7uEVmpOkP/RUiZDY9RMX+QHSKMVbg== |
| Cancel-Lock | sha1:f9Dvb7Tner9lk1hmyA+jVtGPoGA= |
| X-NNTP-Posting-Host | eJwNx8EBgDAIA8CZIATsOIDN/iPo/Y5Iy61IZlDUmumEBmAUrJ7447VzXZc72xo73e+0y4EPIgsR4Q== |
| Xref | csiph.com comp.lang.javascript:30590 |
Show key headers only | View raw
Stefan Ram wrote: > […] we do have > > "use strict"; this.b = 1; > > . That is, when »this.b« is a assigned to - even in strict mode - > a new property »b« is implicitly created. No declaration (with > »var«, »let«, or »const«) is required. > > Is there a name for this »feature« of JavaScript? Property write access. It does not only work with the object referred to by “this” – which, you should keep in mind, does not have to be so particularly in strict mode – but with all objects that have the [[Extensible]] flag set. Also, you want to be careful here: assigning to a property of “this” can result in the creation of the equivalent of a global variable when a function in which it is used is not called as a constructor, and it results in a ReferenceError exception thrown in function context in strict mode if the function is neither called as the method of an object nor as a constructor. “Autovivification” (in C#: null propagation) would certainly be useful at times (very often you just want to get “undefined” from x.y.z when x.y yields “undefined” instead of typeof-testing the whole shebang, and x.y.z = 1 when x.y is “undefined”; consider arrays of objects), and is available in CoffeeScript as the “accessor variant of the existential operator“: x?.y.z <http://stackoverflow.com/questions/15260732/does-typescript-support-the-operator-and-whats-it-called> -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread
Re: not "autovivification", but ...? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-31 17:31 +0200
csiph-web