JavaScript

Practice JavaScript MCQs covering variables, data types, operators, functions, objects, arrays, DOM manipulation, events, ES6+, asynchronous programming, APIs, and modern JavaScript concepts.

3
Topics
304
Total MCQs

JavaScript

Practice JavaScript MCQs covering variables, data types, operators, functions, objects, arrays, DOM manipulation, events, ES6+, asynchronous programming, APIs, and modern JavaScript concepts.

105 MCQs Page 4 of 6
0
0
/ 105
0%
A. trim()
B. strip()
C. trimStart()
D. trimEnd()
Answer: trim() removes whitespace from both ends of a string.
A. 1
B. 2
D. 2.5
Answer: The modulo operator returns the remainder of 5 divided by 2, which is 1.
A. break
B. continue
C. return
D. skip
Answer: continue skips the current iteration and moves to the next one.
A. number
B. bigint
C. object
D. undefined
Answer: The 'n' suffix indicates a BigInt, which is a separate primitive type.
A. concat()
B. merge()
C. join()
D. push()
Answer: concat() is used to merge two or more arrays into a new array.
A. 1
C. true
D. false
Answer: The && operator returns the first falsy value. 1 is truthy, so 0 is returned.
A. size
B. length
C. count
D. index
Answer: The length property returns the number of elements in an array.
A. true
B. false
C. undefined
D. TypeError
Answer: The == operator performs type coercion, so 2 == '2' is true.
A. findIndex()
B. indexOf()
C. find()
D. Both a and b
Answer: Both indexOf() and findIndex() can be used to find an element's index.
A. true
B. false
C. undefined
D. NaN
Answer: Strings are compared lexicographically. 'a' has a smaller Unicode value than 'b'.
A. call()
B. apply()
C. bind()
D. All of the above
Answer: call(), apply(), and bind() all allow setting the 'this' context.
A. 0.3
B. 0.30000000000000004
C. 0.30000000000000004
D. 0.30000000000000004
Answer: Due to floating-point precision, 0.1 + 0.2 results in 0.30000000000000004.
A. setTimeout()
B. setInterval()
C. setRepeat()
D. setRecurring()
Answer: setInterval() repeatedly executes a function at specified intervals.
A. true
B. false
C. undefined
D. TypeError
Answer: [] is coerced to '' and then to 0, so [] == 0 is true.
A. firstChild
B. firstElementChild
C. childNodes[0]
D. All of the above
Answer: All of these methods can access the first child of a node.
A. true
B. false
C. undefined
D. NaN
Answer: Both conditions are true, so the logical AND returns true.
A. toString()
B. String()
C. valueOf()
D. Both a and b
Answer: Both toString() and String() can convert a number to a string.
A. true
B. false
C. undefined
D. NaN
Answer: typeof null returns 'object', so the comparison is true.
A. load
B. DOMContentLoaded
C. ready
D. Both a and b
Answer: Both load and DOMContentLoaded events are used to handle page loading.
A. 1
B. 21
C. NaN
D. TypeError
Answer: The string '2' is coerced to a number, so 2 - 1 = 1.
2 3 4 5 6