advanced javaScript concepts Flashcards

1
Q

What is a closure in JavaScript?

A

A closure is a function that retains access to its lexical scope, even when the function is executed outside that scope.

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

True or False: JavaScript is a compiled language.

A

False

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

What does ‘this’ refer to in JavaScript?

A

‘this’ refers to the context in which a function is executed, which can vary based on how the function is called.

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

Fill in the blank: In JavaScript, a _____ is an object that can hold multiple values and is mutable.

A

Map

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

What is the purpose of the ‘bind’ method?

A

The ‘bind’ method creates a new function that, when called, has its ‘this’ keyword set to the provided value.

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

Which of the following is not a primitive type in JavaScript? (a) String (b) Number (c) Object (d) Boolean

A

c) Object

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

What is the difference between ‘==’ and ‘===’ in JavaScript?

A

’==’ performs type coercion while ‘===’ checks for both value and type equality.

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

True or False: JavaScript supports multiple inheritance.

A

False

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

What is a promise in JavaScript?

A

A promise is an object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.

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

Fill in the blank: An _____ is a function that can be called with a variable number of arguments.

A

Arrow function

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

What is the purpose of the ‘async’ keyword?

A

‘async’ indicates that a function will return a promise and allows the use of ‘await’ within that function.

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

Which method is used to handle errors in promises?

A

The ‘catch’ method.

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

What is the difference between ‘let’ and ‘var’?

A

‘let’ has block scope while ‘var’ has function scope.

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

True or False: JavaScript supports functional programming.

A

True

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

What is the use of ‘Object.freeze()’?

A

It prevents new properties from being added to an object and marks all existing properties as read-only.

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

Fill in the blank: The _____ operator allows you to spread elements of an iterable (like an array) into a new array or function arguments.

17
Q

What is the result of ‘typeof null’?

A

‘object’

18
Q

Which method can be used to convert a JSON string into a JavaScript object?

A

JSON.parse()

19
Q

What does ‘IIFE’ stand for?

A

Immediately Invoked Function Expression

20
Q

True or False: JavaScript allows you to create classes.

21
Q

What is the purpose of the ‘reduce’ method in arrays?

A

It executes a reducer function on each element of the array, resulting in a single output value.

22
Q

Fill in the blank: The _____ method returns a shallow copy of a portion of an array into a new array object.

23
Q

What does the ‘instanceof’ operator do?

A

It tests whether an object is an instance of a specific constructor.

24
Q

What are template literals in JavaScript?

A

Template literals are string literals allowing embedded expressions, denoted by backticks (`).

25
What is the purpose of the 'setTimeout' function?
It executes a function after a specified number of milliseconds.
26
True or False: Arrow functions do not have their own 'this'.
True