121. What is the output of console.log(typeof null)?
- a) "object"
- b) "null"
- c) "undefined"
- d) "string"
typeof null returns "object" due to a historical bug in JavaScript.
Test your knowledge of JavaScript with these interactive multiple-choice questions.
121. What is the output of console.log(typeof null)?
typeof null returns "object" due to a historical bug in JavaScript.
122. Which method removes the last element from an array?
pop() removes and returns the last element of an array.
123. What does NaN stand for?
NaN means "Not a Number" and represents an invalid number.
124. Which operator checks both value and type equality?
=== (strict equality) checks value and type without coercion.
125. What is the scope of a variable declared with let?
let variables are block-scoped (e.g., inside { }).
126. Which function executes after the current call stack is empty?
setTimeout(fn, 0) schedules execution after the current stack clears.
127. What is the output of console.log([] + [])?
128. Which method creates a new array with filtered elements?
filter() returns a new array with elements that pass a test.
129. What does this refer to in an arrow function?
this from their enclosing scope.
130. Which keyword is used to declare a constant?
const declares a block-scoped constant that cannot be reassigned.
131. What is the purpose of use strict?
"use strict" catches common coding mistakes and unsafe actions.
132. What is the output of console.log(0.1 + 0.2 === 0.3)?
0.1 + 0.2 equals 0.30000000000000004.
133. Which method converts a JSON string to an object?
JSON.parse() parses a JSON string into a JavaScript object.
134. What is a closure in JavaScript?
135. Which symbol is used for template literals?
`Hello ${name}`).
136. What does Array.prototype.slice() do?
slice(start, end) returns a new array with selected elements.
137. Which event triggers when a webpage finishes loading?
DOMContentLoaded fires when the HTML is fully parsed (without waiting for stylesheets/images).
138. What is the purpose of Promise.all()?
Promise.all() resolves when all promises succeed or rejects if any fail.
139. Which method adds elements to the beginning of an array?
unshift() adds elements to the start of an array.
140. What is the output of console.log(typeof function(){})?
"function").