JavaScript this Flashcards

1
Q

What is this in JavaScript?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does it mean to say that this is an “implicit parameter”?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When is the value of this determined in a function; call time or definition time?

A

this is determined in a functions call time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you tell what the value of this will be for a particular function or method definition?

A

You cannot determine it until this is called. You need to see the value when it is being called.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you tell what the value of this is for a particular function or method call?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly