YDKNJS this object prototypes Flashcards

1
Q

how to reference a function inside itself?

A

by using it’s name

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

can you reference an anonymous function inside itself?

A

no because it has no name

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

is ‘this’ compile time binding or runtime binding?

A

runtime binding

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

how is ‘this’ determined?

A

by how the function was called not where was it declared

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

what are the rules of binding?

A

1 - default binding -> global object
2 - implicit binding -> obj.fn
3 - explicit binding -> fn.call(obj) or .apply(obj)
4 - hard binding -> wrapping around the fn.call() another function so that it never loses it’s ‘this’binding ex:fn.bind()
5 - new binding -> new foo();

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

how can u always maintain an object binding to a function?

A

using fn.bind(obj)

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

how does the ‘new’ differ in js?

A

t’s not creating a new instance but just invoking a function that happens to be called a constructor

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

what is the order of precedence in ‘this’ binding?

A

1 - new binding
2 - hard binding or explicit binding
3 - implicit binding
4 - default binding

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

what is the ‘this’ binding for .call(null)

A

default binding

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

what is the ‘this’ binding of arrow functions?

A

it binds to the lexical scope of the this of the outer function it’s enclosed in

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

what happens to default binding using strict mode?

A

this becomes undefined

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