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


Groups > comp.lang.javascript > #14587

Re: Function Objects

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="UTF-8"
Message-ID <1615243.oMNUckLgyt@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Organization PointedEars Software (PES)
Date Wed, 20 Jun 2012 15:43:24 +0200
User-Agent KNode/4.4.11
Content-Transfer-Encoding 8Bit
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Subject Re: Function Objects
Newsgroups comp.lang.javascript
References <bm22u7l5dbs0rrdeloru3fd3sct7n8g201@4ax.com> <jrr4cc$k5u$1@news.albasani.net>
Followup-To comp.lang.javascript
MIME-Version 1.0
Lines 40
NNTP-Posting-Date 20 Jun 2012 15:43:24 CEST
NNTP-Posting-Host 1dbbcb1c.newsspool1.arcor-online.net
X-Trace DXC=Rd]99iTC<X0^cW`WBF>WQ<ic==]BZ:af>4Fo<]lROoR1nkgeX?EC@@01CEWAg0_HN5DZm8W4\YJN<UFDj8T]K0?3DmniOZG;K0;R:VYQ02N[=;
X-Complaints-To usenet-abuse@arcor.de
Xref csiph.com comp.lang.javascript:14587

Followups directed to: comp.lang.javascript

Show key headers only | View raw


Stefan Weiss wrote:

> The effect may be easier to understand if you use a simpler
> self-contained example without host objects:
> 
>     var dog = {
>         noise: "wow!",
>         bark: function () { alert(this.noise); }
>     };
> 
>     dog.bark();  // "wow!"
> 
>     var alias = dog.bark;
> 
>     alias();  // "undefined"
> 
> The last line yields "undefined" because |this| in the function body now
> refers to the global object, which has no "noise" property.

Evaluation of `this.noise' throws a TypeError exception in strict mode when 
alias() is called, because `this' would be `undefined' then, and `undefined' 
by definition has no properties.

The strict mode of ECMAScript (introduced in Edition 5 [1]) is particularly 
useful if you want to avoid accessing the global object, but it is neither 
correctly implemented in otherwise conforming implementations yet nor 
available in all implementations at all.  However, if you `"use strict";' 
mode, and test your code with a sufficiently conforming implementation (like 
Google V8 3.7.12.12 in Chrome 17.0.963.78¹), a lot of common programming 
mistakes can be avoided.


PointedEars
___________
¹ This feature and tests thereof are contained in the next version of the
  ECMAScript Support Matrix that I am preparing.

[1] <http://ecma-international.org/ecma-262/5.1/#sec-C>
-- 
When all you know is jQuery, every problem looks $(olvable).

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


Thread

Function Objects Gene Wirchenko <genew@ocis.net> - 2012-06-19 16:35 -0700
  Re: Function Objects Stefan Weiss <krewecherl@gmail.com> - 2012-06-20 02:09 +0200
    Re: Function Objects Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-20 15:43 +0200
    Re: Function Objects Stefan Weiss <krewecherl@gmail.com> - 2012-06-20 17:29 +0200

csiph-web