Quiz: The "this" keyword

After 3 seconds, what will our code log?
 
var myUser = { 
   username: 'tyler', 
age: 25,
email: 'tyler@gmail.com'
};
var getMyUsername = function(){
console.log(this.username);
};
setTimeout(getMyUsername, 3000);
Tyler
Undefined
Throws an error
Null
What's the difference between .call and .apply?
.apply lets you pass in an array as the second argument, .call requires that parameters be listed explicitly
.call lets you pass in an array as the second argument, .apply requires that parameters be listed explicitly
What does .bind do
Invokes a function specifying the context ("this" keyword) inside that function
Returns a new function specifying the context ("this" keyword) inside that function
Binds the state of the function to a specified input field
{"name":"Quiz: The \"this\" keyword", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"After 3 seconds, what will our code log?   var myUser = { username: 'tyler', age: 25, email: 'tyler@gmail.com' }; var getMyUsername = function(){ console.log(this.username); }; setTimeout(getMyUsername, 3000);, What's the difference between .call and .apply?, What does .bind do","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker