JavaScript this Flashcards
What is this in JavaScript?
this is an implicit parameter of all JavaScript functions
this references the current object, the object you are currently within
this is the object to the left of the dot
What does it mean to say that this is an “implicit parameter”?
It means that it is available in a function’s code block even though it was never included in the function’s parameter list or declared with a variable
A variable value inside of a function that you did not declare yourself
When is the value of this determined in a function; call time or definition time?
this is determined in a functions call time
How can you tell what the value of this will be for a particular function or method definition?
You cannot determine it until this is called. You need to see the value when it is being called.
How can you tell what the value of this is for a particular function or method call?
That value of this can be recognized as “the object to the left of the dot”
If there is nothing to “the left of the dot” then it will be the window global object, which is all of your JavaScript