101. What is the output of console.log(1 + +"1")?
- a) 2
- b) "11"
- c) NaN
- d) TypeError
+ converts "1" to a number, resulting in 1 + 1 = 2.
Test your knowledge of JavaScript with these interactive multiple-choice questions.
101. What is the output of console.log(1 + +"1")?
+ converts "1" to a number, resulting in 1 + 1 = 2.
102. Which method creates a new array with elements that pass a test?
filter() returns a new array with elements that satisfy the condition.
103. What is the output of console.log([] == 0)?
[] is converted to 0 during loose equality comparison.
104. Which method executes a reducer function on each element?
reduce() accumulates a single result from the array.
105. What is the output of console.log("5" - 3)?
- operator coerces "5" to a number, resulting in numeric subtraction.
106. Which method checks if at least one element passes a test?
some() returns true if any element satisfies the condition.
107. What is the output of console.log(typeof NaN)?
NaN is technically of type "number" despite meaning "Not a Number".
108. Which method returns the last index of an element in an array?
lastIndexOf() searches from the end of the array.
109. What is the output of console.log(+"Infinity")?
+ converts the string "Infinity" to the number Infinity.
110. Which method returns the primitive value of an object?
valueOf() is called when an object needs to be converted to a primitive value.
111. What is the output of console.log(1 == "1")?
==) performs type coercion, converting the string "1" to the number 1.
112. Which statement about let and const is true?
const allows reassignmentlet doesn't support temporal dead zonelet and const are block-scoped and hoisted but cannot be accessed before declaration (temporal dead zone).
113. What is the output of console.log(typeof (function(){}()))?
undefined.
114. Which method creates a new array with all sub-array elements concatenated recursively?
flat(depth) flattens nested arrays up to the specified depth (default: 1).
115. What does console.log(new String("test") === "test") output?
String object and primitive string are of different types (object vs string).
116. Which operator has the highest precedence?
() has the highest precedence, followed by member access . and new.
117. What is the output of console.log(!!new Boolean(false))?
new Boolean(false) is an object (truthy), so !! converts it to true.
118. Which method prevents extensions to an object?
Object.preventExtensions() disables adding new properties (but allows modifying/deleting existing ones).
119. What is the output of console.log(+"")?
+ coerces an empty string to 0.
120. Which method returns the first element that satisfies a condition?
find() returns the first matching element (or undefined if none).