If I wrote some code like below, when I have some functions and I want to wrap them in an object constructor.
As you can imagine, the third console.log shows false, and I can't think of a way to access the object constructor arguments within deeply.
Is there a way to do this or I have to give up using object constructor?
function Obj(a, b){
this.a = a;
this.b = b;
console.log(this.a == a);
this.fn = function() {
console.log(this.a == a);
function fn2() {
console.log(this.a == a);
// ...
}
fn2();
};
}
var Obj2 = new Obj(0, 1);
Obj2.fn();