Callable Values 25 Flashcards

1
Q

What are the two categories of functions in JS? What do they contain?

A

Ordinary function: can play several roles
- real function
- method
- constructor function
Specialized function: can play one role
- arrow function can only be a real function
- a method can only be a method
- a class can only be a constructor function

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

What is an entity?

A

a JS feature as it lives in RAM. an ordinary function is an entity

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

What is syntax?

A

the code we use to create an entity. function declarations are syntax

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

What is a role?

A

describes how we use entities. an ordinary function can play the role real function or method or constructor

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

What are the two reasons that arrow functions were added to JS?

A

cleaner/more concise syntax for creating functions
- no function keyword
- no parentheses if no parameter
- body can be a code block or an expression
they work better as real functions in methods bc of lexical this

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

What does this do

A

Lets us access the receiver.. the object that the method was called on.

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

What is a callback?

A

a callback is a function that gets passed as an argument to another function and is called asynchronously

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

What is spread syntax?

A

const obj = {1,2,3}
console.log(…obj)
> 1,2,3
destructures values of iterable objects

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

How is calling a function with .call() different than normal call syntax?

A

.call lets you specify this value.. aka it makes this go from implicit to explicit

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