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 3 of 6
0
0
/ 105
0%
A. parseInt()
B. parseFloat()
C. Number()
D. Both a and c
Answer: parseInt() parses a string and returns an integer. Number() can also parse integers.
A. undefined
B. null
C. object
D. NaN
Answer: typeof undefined returns 'undefined'.
A. Array.from()
B. Array.of()
C. Array.create()
D. Array.new()
Answer: Array.from() creates a new array from an iterable or array-like object.
A. h
B. e
C. hello
D. undefined
Answer: charAt(0) returns the character at index 0, which is 'h'.
A. in
B. hasOwnProperty
C. typeof
D. Both a and b
Answer: The 'in' operator and hasOwnProperty() both check for property existence.
A. true
B. false
C. undefined
D. TypeError
Answer: 0 is loosely equal to false (both are falsy).
A. new Date()
B. Date.now()
C. new Date().getTime()
D. All of the above
Answer: All of these methods can be used to get the current date and time.
A. 4
B. 22
C. NaN
D. TypeError
Answer: String concatenation occurs, resulting in '22'.
A. slice()
B. concat()
C. Array.from()
D. All of the above
Answer: All these methods can create shallow copies of an array.
A. 33
B. 123
C. 6
D. NaN
Answer: 1 + 2 = 3, then 3 + '3' = '33' (string concatenation).
A. const
B. let
C. var
D. final
Answer: const is used to declare a constant (read-only) variable.
A. []
B. ''
C. undefined
D. TypeError
Answer: Empty arrays are coerced to empty strings, so '' + '' = ''.
A. Math.ceil()
B. Math.floor()
C. Math.round()
D. Math.trunc()
Answer: Math.floor() returns the largest integer less than or equal to the number.
A. true
B. false
C. undefined
D. NaN
Answer: 0 is falsy, so !!0 returns false.
A. onclick
B. click
C. mouseclick
D. Both a and b
Answer: Both 'click' and 'onclick' are used to handle click events.
A. 32
B. 5
C. 33
D. NaN
Answer: 3 + '3' = '33', then '33' - 1 = 32 (string coerced to number).
A. includes()
B. contains()
C. has()
D. indexOf()
Answer: includes() is used to check if an array contains a specific element.
B. Hello
C. true
D. false
Answer: The || operator returns the first truthy value. 0 is falsy, so 'Hello' is returned.
A. innerHTML
B. outerHTML
C. textContent
D. All of the above
Answer: innerHTML is most commonly used to get or set the HTML content of an element.
A. true
B. false
C. undefined
D. TypeError
Answer: 'JavaScript' is a primitive string, not a String object, so it returns false.
1 2 3 4 5