JavaScript Flashcards

1
Q

Describe scope in Javascript?

A

In javascript, there are two kinds of scope. Global scope and function scope. If the variable definition happens inside of a function the variable is defined with function local scoped. Otherwise, the variable is defined with a global scope meaning it’s created as a member of a global object

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

What is hoisting?

A

Hoisting is when the javascript interpreter assigns variable declarations a value of undefined when it’s evaluating the code.

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

What is the difference between let and var?

A

var is function scoped and when accessed before initialized returns undefined. let is block scoped and returns a reference error when accessed before initialization.

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

what’s the difference between const and let?

A

const and let are both block-scoped and return reference errors when accessed before initialization. The only difference is that const cannot be reassigned, but it is mutable.

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

What is an async function?

A

An async function is an asynchronous function, it always returns a promise.

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

What is a promise?

A

A promise in javascript is a way to return a value in a way that is time-independent. with a promise you can specify chains of asynchronous steps, using the .then(…) method on a returned promise.

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

What is a pure function?

A

A pure function takes arguments and returns values based on those arguments.

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

What is an impure function?

A

Impure functions can mutate objects outside of their scope or produce side effects.

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