1) In an object method, the "this" keyword refers to the _______ of the method?
owner
user
function
element
2) In a browser window, "this" refers to the Global object which is the _____________
IDE
Window object
First object instantiated
Local object
3) When "this" is applied to an inline onclick handler, what is being refered?
HTML Element
The inner HTML of the Element
The function being called
The return value of the function being called
4) What is the output?
var person1 = {
fullName: function() {
return this.firstName + " " + this.lastName
}
}
var person2 = {
firstName: "Leon"
lastName: "Lee"
}
console.log(person1.fullName.call(person2));
[object Window]
person2
person1
Leon Lee
5) In what way can "this" return an undefine when used inside a function?
Default binding already would have "this" return undefine.
Trick question, "this" will refer to a Global object when in a function.
In Javascript strict mode where default binding is not allowed.
If the function is empty, "this" will return undefine since there is nothing to bind to.