Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28033
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: What is this inside a function? |
| Date | Sun, 07 Jun 2015 20:43:15 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 28 |
| Message-ID | <87wpzfi9t8.fsf@bsb.me.uk> (permalink) |
| References | <55745377$0$12997$c3e8da3$5496439d@news.astraweb.com> <878ubvjqgp.fsf@bsb.me.uk> <55749955.4050107@arcor.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="18655"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ahPBDZXEKsIZ6S7c0XFU1JPYy8GAHArs=" |
| Cancel-Lock | sha1:xSwNxWOlxp60gP4SEi3kljFGRg8= sha1:CS/7xvqw+az0MgnFk3Y3gd9L7EE= |
| X-BSB-Auth | 1.533cbdd5db1c4c582909.20150607204315BST.87wpzfi9t8.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.javascript:28033 |
Show key headers only | View raw
"Christoph M. Becker" <cmbecker69@arcor.de> writes:
> Ben Bacarisse wrote:
>
>> Steven D'Aprano <steve@pearwood.info> writes:
>>
>>> Constructors are just functions, except they implicitly return "this",
>>> right?
>>
>> Not really. Constructors are just functions and they can return
>> whatever they like, and when called without new, they return that value.
>> It's the new expression that returns the new object, probably modified
>> by the function that was called. The value the function returns is
>> ignored in a new expression.
>
> The latter is only true if a primitive value would be returned. If,
> however, the return statement's expression evaluates to an object, this
> very object is returned. E.g.
>
> function foo() {return {bar: "baz"}}
> new foo // => {bar: "baz"}
>
> Cf. <http://ecma-international.org/ecma-262/5.1/#sec-13.2.2>.
Ah, yes, I forgot that. Thanks.
--
Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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