Sunday, 12 March 2017

How do I use "this" in this code snippet

function foo(){
    console.log(this.a)
}
var a = 2;
foo(); // returns undefined

this snippet code doesn't print or return 2. what should I do ?!



via amir mohammad golestani

No comments:

Post a Comment