Tuesday, 27 August 2013

javascript init an object without the new keyword

javascript init an object without the new keyword

What's the difference between:
function Foo(){} var foo1 = Foo();
and
var foo2 = new Foo()
As far as I tested, foo1 gives nothing. typeof foo1 is undefined while
with new it's ok as expected.
What's the reason the that without the new keyword I get the undefined
result?

No comments:

Post a Comment