My ECMAScript 7 wishlist

Nicholas C. Zakas standards at
Thu Jun 5 15:42:41 PDT 2014

I wrote this blog post about some of the pain points I'm dealing with 
and dreams of how ES7 might be able to address them:

A short overview in lieu of posting the whole article here:

* `Array.prototype.first()`, `Array.prototype.last()` - return the first 
and last items, respectively.
* `Array.prototype.isEmpty()` - return true when empty (would also be 
nice on strings, maps, etc.).
* `Function.empty` - a standard empty function that can be used when you 
just want an empty function (IMHO, it indicates intent much better than 
other options toda).
* Custom descriptor attributes - David mentioned this likely will never 
happen, which makes me sad. Maybe the decorators proposal solves this 
use case.
* `Object.deepPreventExtensions()`, `Object.deepSeal()`, 
`Object.deepFreeze()` - deep versions of `Object.preventExtensions()`, 
et al.
* `Object.preventUndeclaredGet()` - change an object's behavior to throw 
an error if you try to read from a property that doesn't exist (instead 
of returning `undefine`).
* Lightweight traits - simple syntax sugar for object literals and 
classes to facilitate mixins.

Further rationale and explanation is in the post. The last three, in 
particular, scratch particular itches I currently have.

**Note:** Please don't take these as formal proposals. If any of the 
ideas seems worthwhile, I'm happy to discuss further and/or put together 
an actual proposal.


Nicholas C. Zakas

More information about the es-discuss mailing list