Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28808
| From | Joao Rodrigues <groups_jr-1@yahoo.com.br> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Why JavaScript 'seems' to get addition wrong |
| Date | 2015-10-03 15:55 -0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <mup8b7$i74$1@speranza.aioe.org> (permalink) |
| References | <1588ee9e-9182-41fc-bc23-7b7a33739268@googlegroups.com> <87y4flqp1d.fsf@bsb.me.uk> <1584254.UGq8RPA9Fy@PointedEars.de> |
Thomas 'PointedEars' Lahn wrote:
> Ben Bacarisse wrote:
>
>> AbdulFattah Popoola <abdulapopoola@gmail.com> writes:
>>> One of the most popular gotchas of JavaScript is its behaviour when
>>> adding operands. For example, the output of {} + 2 is different from 2
>>> + {}.
>>
>> That's not an example of addition. I think it's better to say that one
>> of the gochas of EcmaScript is that + means more than one thing.
>
> If it were another programming language, you might just say that the
> operator “+” is overloaded: it does either addition or string concatenation
> in ECMAScript, depending on the type of its operands:
>
> window.alert(Array(16).join("wat" - 1) + " Batman!");
>
> (Shamelessly stolen from <https://www.destroyallsoftware.com/talks/wat> when
> it was still working ;-))
I recall Brendan Eich commenting about this and other weird examples in
one of his presentations.
>
>>> I explained why the puzzling results occur in this post:
>>> http://abdulapopoola.com/2015/09/30/why-javascript-seems-to-get-addition-wrong/.
>>>
>>> Please do share your feedback.
>>
>> Share you explanation here, and I'll share my feedback here.
>
> They are posting via Google Groups; you can be quite certain that they do
> not even know what “here” (Usenet) actually is.
AbdulFattah is often posting at the JS Mentors group which seems to be
dying out. Maybe this is why he has recurred to c.l.js.
<https://groups.google.com/forum/?fromgroups#!forum/jsmentors>
--
Joao Rodrigues
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Why JavaScript 'seems' to get addition wrong AbdulFattah Popoola <abdulapopoola@gmail.com> - 2015-10-02 08:07 -0700
Re: Why JavaScript 'seems' to get addition wrong Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-10-02 16:16 +0100
Re: Why JavaScript 'seems' to get addition wrong AbdulFattah Popoola <abdulapopoola@gmail.com> - 2015-10-02 19:22 -0700
Re: Why JavaScript 'seems' to get addition wrong Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-10-03 05:24 +0200
Re: Why JavaScript 'seems' to get addition wrong Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-10-03 15:55 -0300
csiph-web