JavaScript Language feature Idea

Bruno Jouhier bjouhier at gmail.com
Tue Apr 19 08:00:42 UTC 2016


Adding `last` to `Array.prototype` is no different than adding `endsWith`
to `String.prototype`. ES2015 did it.

It won't break most existing code that defines `Array.prototype.last`. Such
code will just overwrite the new `last` method and will continue to work as
before.

You won't be able to mix old libraries that have their own `last` method
with new code if the methods behave differently but that's a different
story; that's not breaking existing web pages.

What will break though is existing code that test the existence of
`Array.prototype.last`; but `String.prototype.endsWith` had the same issue.

last(1) would return last but one, and last() would be the same as last(0)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160419/1c9bc3a5/attachment.html>


More information about the es-discuss mailing list