JavaScript Language feature Idea

Alexander Jones alex at weej.com
Tue Apr 19 07:41:45 UTC 2016


This is why we can't have nice things... Literally anything we do with the
language *at all* can collide with libraries. Introducing new syntax? Code
that was using eval and throwing syntax errors is now behaving differently
and you 'broke the web'... Adding a `Symbol.last` method to `Array#`?
People who were abusing Arrays as property bags might have code that was
adding that key as a property already and you 'broke the web'...

If this is seriously the attitude we're taking as a community, we should
stop wasting our time and just accept that WebAssembly is the only
reasonable way forward. All of these modern nice-to-haves are a crutch and
a distraction from this and obfuscate the need for a real solution.

Of course, we cleaned up parts of the language once already with 'use
strict'. I don't see why we can't do it again once or twice a decade...

Alex

On Tuesday, 19 April 2016, Bob Myers <rtm at gol.com> wrote:

> Please go back and read the existing threads. We've been over this
> territory ad nauseum.
>
> Yes, of course `array[-1]` would break the web and that's why no one is
> seriously proposing that.
>
> As already discussed extensively, `Array#last` may be an option, but it
> could collide with libraries or other code which extends `Array.prototype`,
> and they seem too specialized (why not also `lastButOne`?).
>
> Bob
>
> On Tue, Apr 19, 2016 at 10:47 AM, Bruno Jouhier <bjouhier at gmail.com
> <javascript:_e(%7B%7D,'cvml','bjouhier at gmail.com');>> wrote:
>
>> Why new syntax here? This is just a method that's missing:
>> `array.last(n)`.
>>
>> `array[-1]` would break things and it is difficult to find out where.
>> Consider:
>>
>> ``` javascript
>> for (var i = array.length - 1; array[i]; i--) doSomething(array[i]);
>> ```
>>
>> Not the best way to write such a loop but changing `array[-1]` would
>> break it.
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160419/965ea28f/attachment.html>


More information about the es-discuss mailing list