JavaScript MCQ with Answers
1. Which keyword is used to declare a variable in JavaScript?
2. What is the correct way to write a comment in JavaScript?
3. Which built-in method converts a string to lowercase letters?
4. Which of the following is not a JavaScript data type?
5. What will the following code output?
console.log(2 + '2');
6. How do you create a new object in JavaScript?
7. What is the output of the following code?
console.log(typeof NaN);
8. What does the "this" keyword refer to in JavaScript?
9. Which function is used to parse a string to an integer in JavaScript?
10. What is the correct way to write an if statement in JavaScript?
If you want to Learn JavaScript Click Here
11. Which operator is used to compare both value and type in JavaScript?
12. What will the following code output?
console.log(2 * '2');
13. How do you add a single-line comment in JavaScript?
14. Which function is used to round a number to the nearest integer in JavaScript?
15. What does the "typeof" operator return for an array?
16. How do you access the length of an array in JavaScript?
17. What is the correct way to check if a variable is an array in JavaScript?
18. What is the result of the following code?
console.log(3 + 2 + '7');
19. How do you convert a string to a number in JavaScript?
20. What will the following code output?
console.log(typeof null);
21. Which function is used to remove the last element from an array in JavaScript?
22. What is the output of the following code?
console.log(0.1 + 0.2 == 0.3);
23. Which method is used to add new elements to the end of an array in JavaScript?
24. How do you check if a variable has a value of NaN in JavaScript?
25. What will the following code output?
console.log(typeof []);
26. Which operator is used for exponentiation in JavaScript?
27. What does the "continue" statement do in a loop?
28. What is the output of the following code?
console.log(4 > 3 > 2);
29. Which method is used to remove the first element from an array in JavaScript?
30. What is the correct way to define a function in JavaScript?
Hey, We hope this quiz was helpful for you. If this quiz was helpful then please drop how many questions you attempt correct on the comment section below.