closure not working
- by dorelal
var Dog = function() {
var _instance = 'hello world';
return function() {
console.log(this._instance);
}
} (); //note that it is self invoking function
var l = new Dog(); //#> undefined
In the above case I was expecting output of 'hello world'.
Why this._instance is not accessing the the varible which should be accessible by virtue of closure. I tested this in FF and am getting undefined.