3 ms·
(apologies for the double post) Doing away with `new` in this way also has the added advantage of allowing people to create objects with varargs, which is impo
by jayferd 15y ago
(apologies for the double post)
Doing away with `new` in this way also has the added advantage of allowing people to create objects with varargs, which is impossible otherwise.
- ricardobeat 15y agonew MyClass('bacon', 'eggs') is perfectly possible, or am I misunderstanding your sentence? How about exposing creation via `P.create`, `P.inherit` or something like it?
- jayferd 15y agoright, but say you had an `var array = ['bacon', 'eggs']`. You can call a function with these arguments with `fn.apply(null, array)` (yeah it's ugly but it's how it's done in JS). This doesn't work with the `new` keyword. EDIT: also, a class method would hurt your script's minifier performance. ...and at that point you may as well just call the function anyways :)