Question:

What does the following code print to the console?

var an_object = {
  hat: function() { return (this === an_object); }
}
console.log(an_object.hat());

Answer:

true

The hat() method is bound to an_object and the this keyword within the hat() method refers to an_object.


Keywords:

© 2017 QuizBucket.org