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 5 of 6
0
0
/ 105
0%
A. new
B. create
C. instance
D. class
Answer: The 'new' keyword is used to create an instance of a class.
A. true
B. false
C. undefined
D. NaN
Answer: The logical NOT operator reverses the boolean value, so !true is false.
A. window.location.href
B. document.URL
C. location.href
D. All of the above
Answer: All of these methods can be used to get the current URL.
A. 10
B. 55
C. NaN
D. TypeError
Answer: The number is coerced to a string, resulting in concatenation: '55'.
A. toLowerCase()
B. lowerCase()
C. toLower()
D. caseLower()
Answer: toLowerCase() converts a string to lowercase letters.
A. 20
B. 14
C. 24
D. 12
Answer: Multiplication has higher precedence, so 3 * 4 = 12, then 2 + 12 = 14.
A. eval()
B. parse()
C. execute()
D. run()
Answer: eval() evaluates JavaScript code represented as a string.
A. true
B. false
C. undefined
D. TypeError
Answer: === checks both value and type. 0 is a number, false is a boolean.
A. Math.max()
B. Math.max.apply()
C. Math.max(...array)
D. All of the above
Answer: All of these methods can be used to find the maximum value in an array.
A. function
B. object
C. undefined
D. arrow
Answer: Arrow functions are a type of function, so typeof returns 'function'.
A. onsubmit
B. submit
C. formsubmit
D. Both a and b
Answer: Both 'submit' and 'onsubmit' can be used to handle form submissions.
A. 1
B. 2
C. 3
Answer: 10 divided by 3 leaves a remainder of 1.
A. import
B. require
C. include
D. Both a and b (depending on environment)
Answer: import is used in ES modules, while require is used in CommonJS.
A. 6
B. 23
C. NaN
D. TypeError
Answer: The string '3' is coerced to a number, so 2 * 3 = 6.
A. toUpperCase()
B. upperCase()
C. toUpper()
D. caseUpper()
Answer: toUpperCase() converts a string to uppercase letters.
A. 3
B. 52
C. NaN
D. TypeError
Answer: The string '5' is coerced to a number, so 5 - 2 = 3.
A. Object.defineProperty()
B. Object.assign()
C. Dot notation or bracket notation
D. All of the above
Answer: All of these methods can be used to add properties to an object.
A. true
B. false
C. undefined
D. NaN
Answer: 3 > 2 is true (1), then 1 > 1 is false.
A. window
B. global
C. Both a and b
D. timer
Answer: In browsers, window has timer functions; in Node.js, global has them.
A. 64
B. 1234
C. 10
D. NaN
Answer: 1 + 2 + 3 = 6, then 6 + '4' = '64' (string concatenation).
3 4 5 6