JavaScript Flashcards

(300 cards)

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

Why are closures useful?

A

They allow functions to have private variables and enable powerful patterns like function factories and partial application.

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

What is hoisting in JavaScript?

A

Hoisting is JavaScript’s default behavior of moving declarations to the top of the current scope.

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

What gets hoisted?

A

var and function declarations are hoisted. let and const are hoisted but not initialized.

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

What is lexical scope?

A

Lexical scope refers to the fact that a function’s scope is determined by its position in the source code.

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

What does the this keyword refer to?

A

this refers to the object that is executing the current function.

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

How does this behave in arrow functions?

A

Arrow functions inherit this from their lexical scope; they do not bind their own this.

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

What is the event loop?

A

The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.

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

What is the call stack?

A

The call stack is a data structure that keeps track of function calls in JavaScript.

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

What is the task queue?

A

A queue that holds callback functions to be executed after the current call stack is empty.

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

What is a promise in JavaScript?

A

A Promise is an object representing the eventual completion or failure of an asynchronous operation.

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

What are the states of a promise?

A

Pending, Fulfilled, and Rejected.

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

What does async/await do?

A

It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.

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

What is prototypal inheritance?

A

A mechanism by which an object can inherit properties and methods from another object via its prototype.

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

What is the difference between \_\_proto\_\_ and prototype?

A

\_\_proto\_\_ is the actual object used in the prototype chain; prototype is a property of constructor functions used to define properties on instances.

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

What is type coercion in JavaScript?

A

Type coercion is the automatic or implicit conversion of values from one data type to another.

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

What is the difference between == and ===?

A

== compares values with type coercion; === compares values without coercion.

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

What causes a memory leak in JavaScript?

A

Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.

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

How does garbage collection work in JavaScript?

A

It automatically frees up memory by removing objects that are no longer reachable.

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

What is the difference between null and undefined?

A

undefined is a variable declared but not assigned. null is an intentional absence of any value.

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

What happens when you access a non-existent property?

A

undefined is returned.

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

Explain 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
23
Q

Reason why are closures useful?

A

They allow functions to have private variables and enable powerful patterns like function factories and partial application.

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

Explain hoisting in JavaScript?

A

Hoisting is JavaScript’s default behavior of moving declarations to the top of the current scope.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
26
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
27
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
28
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
29
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
30
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
31
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
32
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
33
What are the states of a promise?
Pending, Fulfilled, and Rejected.
34
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
35
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
36
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
37
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
38
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
39
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
40
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
41
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
42
What happens when you access a non-existent property?
`undefined` is returned.
43
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
44
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
45
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
46
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
47
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
48
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
49
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
50
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
51
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
52
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
53
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
54
What are the states of a promise?
Pending, Fulfilled, and Rejected.
55
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
56
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
57
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
58
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
59
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
60
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
61
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
62
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
63
What happens when you access a non-existent property?
`undefined` is returned.
64
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
65
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
66
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
67
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
68
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
69
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
70
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
71
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
72
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
73
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
74
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
75
What are the states of a promise?
Pending, Fulfilled, and Rejected.
76
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
77
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
78
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
79
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
80
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
81
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
82
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
83
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
84
What happens when you access a non-existent property?
`undefined` is returned.
85
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
86
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
87
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
88
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
89
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
90
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
91
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
92
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
93
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
94
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
95
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
96
What are the states of a promise?
Pending, Fulfilled, and Rejected.
97
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
98
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
99
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
100
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
101
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
102
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
103
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
104
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
105
What happens when you access a non-existent property?
`undefined` is returned.
106
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
107
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
108
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
109
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
110
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
111
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
112
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
113
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
114
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
115
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
116
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
117
What are the states of a promise?
Pending, Fulfilled, and Rejected.
118
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
119
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
120
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
121
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
122
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
123
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
124
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
125
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
126
What happens when you access a non-existent property?
`undefined` is returned.
127
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
128
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
129
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
130
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
131
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
132
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
133
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
134
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
135
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
136
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
137
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
138
What are the states of a promise?
Pending, Fulfilled, and Rejected.
139
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
140
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
141
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
142
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
143
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
144
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
145
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
146
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
147
What happens when you access a non-existent property?
`undefined` is returned.
148
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
149
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
150
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
151
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
152
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
153
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
154
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
155
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
156
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
157
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
158
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
159
What are the states of a promise?
Pending, Fulfilled, and Rejected.
160
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
161
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
162
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
163
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
164
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
165
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
166
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
167
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
168
What happens when you access a non-existent property?
`undefined` is returned.
169
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
170
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
171
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
172
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
173
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
174
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
175
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
176
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
177
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
178
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
179
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
180
What are the states of a promise?
Pending, Fulfilled, and Rejected.
181
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
182
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
183
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
184
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
185
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
186
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
187
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
188
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
189
What happens when you access a non-existent property?
`undefined` is returned.
190
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
191
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
192
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
193
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
194
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
195
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
196
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
197
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
198
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
199
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
200
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
201
What are the states of a promise?
Pending, Fulfilled, and Rejected.
202
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
203
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
204
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
205
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
206
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
207
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
208
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
209
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
210
What happens when you access a non-existent property?
`undefined` is returned.
211
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
212
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
213
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
214
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
215
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
216
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
217
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
218
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
219
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
220
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
221
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
222
What are the states of a promise?
Pending, Fulfilled, and Rejected.
223
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
224
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
225
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
226
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
227
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
228
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
229
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
230
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
231
What happens when you access a non-existent property?
`undefined` is returned.
232
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
233
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
234
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
235
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
236
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
237
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
238
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
239
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
240
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
241
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
242
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
243
What are the states of a promise?
Pending, Fulfilled, and Rejected.
244
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
245
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
246
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
247
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
248
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
249
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
250
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
251
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
252
What happens when you access a non-existent property?
`undefined` is returned.
253
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
254
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
255
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
256
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
257
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
258
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
259
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
260
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
261
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
262
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
263
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
264
What are the states of a promise?
Pending, Fulfilled, and Rejected.
265
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
266
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
267
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
268
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
269
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
270
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
271
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
272
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
273
What happens when you access a non-existent property?
`undefined` is returned.
274
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
275
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
276
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
277
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
278
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
279
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.
280
Describe how `this` behave in arrow functions?
Arrow functions inherit `this` from their lexical scope; they do not bind their own `this`.
281
Explain the event loop?
The event loop is the mechanism that handles asynchronous callbacks in JavaScript by dequeuing tasks from the event queue when the call stack is clear.
282
Explain the call stack?
The call stack is a data structure that keeps track of function calls in JavaScript.
283
Explain the task queue?
A queue that holds callback functions to be executed after the current call stack is empty.
284
Explain a promise in JavaScript?
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
285
What are the states of a promise?
Pending, Fulfilled, and Rejected.
286
What does `async/await` do?
It allows writing asynchronous code that looks synchronous, by pausing execution until a Promise resolves.
287
Explain prototypal inheritance?
A mechanism by which an object can inherit properties and methods from another object via its prototype.
288
Explain the difference between `__proto__` and `prototype`?
`__proto__` is the actual object used in the prototype chain; `prototype` is a property of constructor functions used to define properties on instances.
289
Explain type coercion in JavaScript?
Type coercion is the automatic or implicit conversion of values from one data type to another.
290
Explain the difference between `==` and `===`?
`==` compares values with type coercion; `===` compares values without coercion.
291
What causes a memory leak in JavaScript?
Memory leaks occur when references to unused objects are unintentionally kept, preventing garbage collection.
292
Describe how garbage collection work in JavaScript?
It automatically frees up memory by removing objects that are no longer reachable.
293
Explain the difference between `null` and `undefined`?
`undefined` is a variable declared but not assigned. `null` is an intentional absence of any value.
294
What happens when you access a non-existent property?
`undefined` is returned.
295
Explain a closure in JavaScript?
A closure is a function that retains access to its lexical scope even when the function is executed outside that scope.
296
Reason why are closures useful?
They allow functions to have private variables and enable powerful patterns like function factories and partial application.
297
Explain hoisting in JavaScript?
Hoisting is JavaScript's default behavior of moving declarations to the top of the current scope.
298
What gets hoisted?
`var` and function declarations are hoisted. `let` and `const` are hoisted but not initialized.
299
Explain lexical scope?
Lexical scope refers to the fact that a function's scope is determined by its position in the source code.
300
What does the `this` keyword refer to?
`this` refers to the object that is executing the current function.