JavaScript This Flashcards
What is this in JavaScript?
key word in referring to the calling object
What does it mean to say that this is an “implicit parameter”?
not in the function code block parameters to begin with
When is the value of this determined in a function; call time or definition time?
called time
What does this refer to in the following code snippet?
var character = {
firstName: ‘Mario’,
greet: function () {
var message = ‘It's-a-me, ‘ + this.firstName + ‘!’;
console.log(message);
}
};
inside the character object
Given the above character object, what is the result of the following code snippet? Why?
character.greet();
Its a me Mario in the console. because it takes the value of firstname of Mario
Given the above character object, what is the result of the following code snippet? Why?
var hello = character.greet;
hello();
undefined
How can you tell what the value of this will be for a particular function or method definition?
ignore
How can you tell what the value of this is for a particular function or method call?
look to the left the closeest object id no object it is the window