Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28039
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Calling constructor function with or without new |
| Date | 2015-06-07 21:50 -0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <ml2osq$3q6$1@speranza.aioe.org> (permalink) |
| References | <55745048$0$13014$c3e8da3$5496439d@news.astraweb.com> <ml2021$1at3$1@adenine.netfront.net> |
On 07/06/15 14:46, Martin Honnen wrote:
> Steven D'Aprano wrote:
>> I'm using Rhino. What's the difference between calling a constructor
>> with or
>> without new?
>>
>> js> var x = Number("123");
>> js> print(x);
>> 123
>> js> typeof x;
>> number
>
> As you use Rhino which I think did never get updated to implement
> ECMAScript 5 you might want to download
> http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf
> and read section "15.7.1 The Number Constructor Called as a Function"
> which says "When Number is called as a function rather than as a
> constructor, it performs a type conversion." and defines
> Number ( [ value ] )
> as
> Returns a number value (not a Number object) computed by
> ToNumber(value) if value was supplied,
> else returns +0.
>
> The type conversions "ToNumber" performs depending on the type of the
> value are defined in section "9.3" of that PDF.
>
One can read the online version at:
<http://ecma-international.org/ecma-262/5.1/#sec-15.7.1>
<http://ecma-international.org/ecma-262/5.1/#sec-9.3>
--
Joao Rodrigues
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Calling constructor function with or without new Steven D'Aprano <steve@pearwood.info> - 2015-06-08 00:08 +1000
Re: Calling constructor function with or without new Martin Honnen <mahotrash@yahoo.de> - 2015-06-07 19:46 +0200
Re: Calling constructor function with or without new Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-06-07 21:50 -0300
Re: Calling constructor function with or without new Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-09 15:05 +0200
Re: Calling constructor function with or without new Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-06-09 12:45 -0300
Re: Calling constructor function with or without new Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-09 18:32 +0200
Re: Calling constructor function with or without new Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-06-09 14:51 -0300
Re: Calling constructor function with or without new Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-09 22:39 +0200
Re: Calling constructor function with or without new Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-06-09 19:36 -0300
Re: Calling constructor function with or without new Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-10 18:14 +0200
Re: Calling constructor function with or without new Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-06-10 14:13 -0300
Re: Calling constructor function with or without new Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-10 19:34 +0200
Re: Calling constructor function with or without new Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-06-10 14:57 -0300
Re: Calling constructor function with or without new Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-10 20:00 +0200
Re: Calling constructor function with or without new Dr J R Stockton <reply1500@merlyn.demon.co.uk.invalid> - 2015-06-11 21:44 +0100
Re: Calling constructor function with or without new Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2015-06-11 10:36 +0200
Re: Calling constructor function with or without new Scott Sauyet <scott.sauyet@gmail.com> - 2015-06-11 06:16 -0700
Re: Calling constructor function with or without new "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-06-11 20:40 -0700
csiph-web