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: parseInt() parses a string and returns an integer. Number() can also parse integers.
Answer: typeof undefined returns 'undefined'.
Answer: Array.from() creates a new array from an iterable or array-like object.
Answer: charAt(0) returns the character at index 0, which is 'h'.
Answer: The 'in' operator and hasOwnProperty() both check for property existence.
Answer: 0 is loosely equal to false (both are falsy).
Answer: All of these methods can be used to get the current date and time.
Answer: String concatenation occurs, resulting in '22'.
Answer: All these methods can create shallow copies of an array.
Answer: 1 + 2 = 3, then 3 + '3' = '33' (string concatenation).
Answer: const is used to declare a constant (read-only) variable.
Answer: Empty arrays are coerced to empty strings, so '' + '' = ''.
Answer: Math.floor() returns the largest integer less than or equal to the number.
Answer: 0 is falsy, so !!0 returns false.
Answer: Both 'click' and 'onclick' are used to handle click events.
Answer: 3 + '3' = '33', then '33' - 1 = 32 (string coerced to number).
Answer: includes() is used to check if an array contains a specific element.
Answer: The || operator returns the first truthy value. 0 is falsy, so 'Hello' is returned.
Answer: innerHTML is most commonly used to get or set the HTML content of an element.
Answer: 'JavaScript' is a primitive string, not a String object, so it returns false.