Last active
December 15, 2015 04:50
-
-
Save vernonk/5204305 to your computer and use it in GitHub Desktop.
Inspired by @Jack_Franklin here's another little JS quiz.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMe() { | |
console.log(this); // what is `this`? | |
} | |
var superman = { | |
fname: "Clark", | |
lname: "Kent" | |
}; | |
getMe.call(superman); // what is `this` in getMe? | |
var myObj = { | |
sayWhat: function() { | |
console.log(this); // what is `this`? | |
} | |
}; | |
$('.el').each(function() { | |
console.log(this); // what is `this`? | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's probably just semantics (i.e. the way I'm reading it) but the jQuery iterator isn't a reference to the current jQuery Object of the
.el
but a reference to the DOM node itself. Unlike a lot of other jQuery methods,this
actually has to be wrapped in$()
to get a jQuery Object.