Wednesday, 16 May 2018

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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...