Sunday 2 December 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...