obsoleting the "new" keyword

Peter Michaux petermichaux at gmail.com
Sat Jan 17 12:51:06 PST 2009

On Wed, Jan 14, 2009 at 11:58 AM, Juriy Zaytsev <kangax at gmail.com> wrote:
> On Jan 14, 2009, at 1:51 PM, Peter Michaux wrote:
> [...]
> Yes.
> Needing "new" makes some things unnecessarily bulky.
> var pts = getRows().map(function(r) {return new Point(r);});
> verses just
> var pts = getRows().map(Point);
> This is indeed a frequent annoyance.
> It wouldn't be so bad if there was `Function.prototype.construct` or
> `Function.prototype.new` (or something along these lines).
> Are there any plans to include such facility in ES3.1 (or any objections
> against it?)
> [...]

Ding, ding, ding! I was hoping someone would suggest this but I don't
know how it can work.

In order to be able to do the following, the Point.new function would
need to be bound to Point and that is not the way properties work in
JavaScript (which is unfortunate in some cases but beneficial in

var pts = getRows().map(Point.new);

When Point.new is called inside map, the "this" object will be the
global object, not the Point object.


More information about the Es-discuss mailing list