An implementation of new using new is kind of weird...
On Jul 16, 2011 1:54 AM, Dmitry Baranovskiy dmitry.baranovs...@gmail.com
wrote:
I would suggest to fix prototype reference and ensure that all objects
that
are returned from constructor are taken into account be it functions or
anything
If your environment has `Object.create` implemented you dont have to
use `new`, but Object.create itself would use new unless implemented
by the JavaScript engine. An implementation of `Object.create` is the
following:
if (!Object.create) {
Object.create = function (o) {
if
Hi,
I think you should je return whaterver is returned by the constructor.
And typeof {}==='object'
All lowercase
Your second call should be apply
And constructor isn't a property of instances, it is a property of the
prototype if i remember welll.
I'll post an implementation later if noone
On Fri, Jul 15, 2011 at 1:38 PM, Xavier MONTILLET
xavierm02@gmail.com wrote:
Hi,
I think you should je return whaterver is returned by the constructor.
Nah, construtors always return an object. If you don't (ie. `return
5;`), the original new instance is returned anyways.
I would suggest
I would suggest to fix prototype reference and ensure that all objects that
are returned from constructor are taken into account be it functions or
anything else. Something across these lines:
function NEW(f) {
var obj,
out;
if (Object.create) {
obj =