Difference Between 'var A = B' And 'this.a = B'
I have been dealing and learning about Objects and OOP in JS in the past few days and I good a basic understanding how they work now. One thing that bothers me, and I have problems
Solution 1:
Nope youre wrong. var adds a property to the current functional context:
obj={
add:function(){
var plane="test";
this.bird="test2";
}//plane gets deleted right here as it isnt used anymoreand it was never part of obj
};
obj.add();
obj.plane;//never existed
console.log(obj.bird);
Post a Comment for "Difference Between 'var A = B' And 'this.a = B'"