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.
Answer: trim() removes whitespace from both ends of a string.
Answer: The modulo operator returns the remainder of 5 divided by 2, which is 1.
Answer: continue skips the current iteration and moves to the next one.
Answer: The 'n' suffix indicates a BigInt, which is a separate primitive type.
Answer: concat() is used to merge two or more arrays into a new array.
Answer: The && operator returns the first falsy value. 1 is truthy, so 0 is returned.
Answer: The length property returns the number of elements in an array.
Answer: The == operator performs type coercion, so 2 == '2' is true.
Answer: Both indexOf() and findIndex() can be used to find an element's index.
Answer: Strings are compared lexicographically. 'a' has a smaller Unicode value than 'b'.
Answer: call(), apply(), and bind() all allow setting the 'this' context.
Answer: Due to floating-point precision, 0.1 + 0.2 results in 0.30000000000000004.
Answer: setInterval() repeatedly executes a function at specified intervals.
Answer: [] is coerced to '' and then to 0, so [] == 0 is true.
Answer: All of these methods can access the first child of a node.
Answer: Both conditions are true, so the logical AND returns true.
Answer: Both toString() and String() can convert a number to a string.
Answer: typeof null returns 'object', so the comparison is true.
Answer: Both load and DOMContentLoaded events are used to handle page loading.
Answer: The string '2' is coerced to a number, so 2 - 1 = 1.