Friday 31 March 2017

How does 'this' works in javascript?

hi i am a little confusion on how exactly this works in javascript.Based on this example:



var myFunction = function(){
function testMe(){
console.log(this) --------> DOMwindow
}
console.log(this) ---------> myFunction
}


var myvariable = new myFunction();


What is happening here?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...