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


Groups > comp.lang.javascript > #28091

Re: What is this inside a function?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!1.eu.feeder.erje.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: What is this inside a function?
Date Fri, 12 Jun 2015 19:19:18 +0200
Organization PointedEars Software (PES)
Lines 41
Message-ID <1908572.Dhjy60Y1dk@PointedEars.de> (permalink)
References <55745377$0$12997$c3e8da3$5496439d@news.astraweb.com> <878ubvjqgp.fsf@bsb.me.uk> <55749955.4050107@arcor.de> <1622672.QCbqgxkKEs@PointedEars.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Trace solani.org 1434129735 29794 eJwNxMEBwCAIA8CVhEKi4zQI+4/Q3uPygaEYSEROTit2BntGdqH+KxPOBsvWSzTovGd5lLv4ASnbEQw= (12 Jun 2015 17:22:15 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Fri, 12 Jun 2015 17:22:15 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwNyMkNADEIBLCWMgEGUQ7H0n8Jm5clmxBsVxrV1tYLIoV8Eb3Bh7cc5HeunRJse0/kbt6B1nIYDqgNtwc/RaQVjA==
Cancel-Lock sha1:K1fn5lk+fgtOENco/W1hLO/+L3s=
X-NNTP-Posting-Host eJwFwYERACEIA7CV5KAVx/m3dP8RTJAM3l0EC4bV9JyU/injLAqaNtPpXXEX1J0D5V6lLx4xuBF6
Xref csiph.com comp.lang.javascript:28091

Show key headers only | View raw


Thomas 'PointedEars' Lahn wrote:

> Christoph M. Becker wrote:
>> Cf. <http://ecma-international.org/ecma-262/5.1/#sec-13.2.2>.
> 
> Correct, and this has practical implications:
> 
>   function Person2(name, age)
>   {
>     if (!(this instanceof Person2)) return new Person2(name, age);
>     
>     this.name = name;
>     this.age = age;
>   }
> 
> and with JSX:
> 
>   function Person2(name, age)
>   {
>     if (!(this instanceof Person2)) return Person2.construct(arguments);
>     
>     this.name = name;
>     this.age = age;
>   }
> 
> See also Function.prototype.construct() and
> Function.prototype.construct2() in
> <http://PointedEars.de/wsvn/JSX/trunk/object.js>.

Du not bother looking for .construct2(); it went the way of the dinosaur 
with r510 last year already :)  The new .construct() does not use eval() 
anymore, and as it was also superior to the .construct2() that Asen Bozhilov 
suggested, I have removed the latter method.

<http://pointedears.de/wsvn/JSX/trunk/object.js?op=diff&rev=510>

-- 
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 — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

What is this inside a function? Steven D'Aprano <steve@pearwood.info> - 2015-06-08 00:21 +1000
  Re: What is this inside a function? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-07 19:58 +0100
    Re: What is this inside a function? "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-06-07 21:19 +0200
      Re: What is this inside a function? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-07 20:43 +0100
      Re: What is this inside a function? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-08 01:08 +0200
        Re: What is this inside a function? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-12 19:19 +0200
    Re: What is this inside a function? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-07 23:48 +0200

csiph-web