JavaScript MCQ Questions with Answers
1. Which of the following is a JavaScript data type?
A. Float
B. String
C. Decimal
D. Double
Answer: B
2. What is the correct syntax to print a message in the console in JavaScript?
A. print("Hello")
B. console.log("Hello")
C. log.console("Hello")
D. printf("Hello") Answer: B
3. Which symbol is used for single-line comments in JavaScript?
A. <!-- -->
B. #
C. //
D. **
Answer: C
4. How do you declare a variable in JavaScript?
A. v x = 10
B. dim x = 10
C. var x = 10
D. int x = 10
Answer: C
5. What is the output of: typeof [] ?
A. Object
B. Array
C. List
D. Undefined
Answer: A
6. Which method is used to convert JSON data to a JavaScript object?
A. JSON.stringify()
B. JSON.parse()
C. parse.JSON()
D. JSON.convert() Answer: B
7. Which company developed JavaScript?
A. Microsoft
B. Mozilla
C. Sun Microsystems
D. Netscape Answer: D
8. What does DOM stand for in JavaScript?
A. Data Object Model
B. Document Object Model
C. Dynamic Object Management
D. Digital Object Model
Answer: B
9. Which function is used to delay execution in JavaScript?
A. wait()
B. setTimeout()
C. pause()
D. sleep() Answer: B
10. Which operator is used to compare both value and type in JavaScript?
A. ==
B. =
C. ===
D. !=
Answer: C