JavaScript MCQ Questions with Answers – Part 1

JavaScript MCQ Techhyme Part 1

JavaScript is one of the most popular programming languages in the world and is basically the language of the web. It is a lightweight, cross-platform, and interpreted language, primarily used for web development and backend development.

Also Read:

JavaScript is a language that is used widely on both the client and server sides of development. It offers a vast standard library that has a wide variety of functions and methods available to help in the process of development, making the entire process easier and hassle-free.

This article contains 50 JavaScript Multiple-Choice Questions with Answers. These JavaScript MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of JavaScript. You will have to read all the given answers.

1. JavaScript is a version of

A. Java
B. Live Script
C. C++
D. VBScrip

Correct Answer: B

2. A JavaScript must reside within the

A. <object> tag
B. <applet> tag
C. <script> tag
D. <cgi> tag

Correct Answer: C

3. The Submit button is a type of

A. Object
B. Method
C. Property
D. Variable

Correct Answer: A

4. The background color of a document is a type of

A. Object
B. Method
C. Property
D. Variable

Correct Answer: C

5. Write () is a type of

A. Object
B. Method
C. Property
D. Variable

Correct Answer: B

6. A dot is used to

A. Identify a JavaScript comment
B. Separate lines of a JavaScript
C. End a JavaScript statement
D. Separate an object name from either a property or a method

Correct Answer: D

7. What is it called when a person clicks a button on a form displayed by your JavaScript?

A. Event
B. Reaction
C. Rollover
D. Mouse rollover

Correct Answer: A

8. What part of your JavaScript reacts to someone clicking a button on a form displayed by your JavaScript?

A. Main
B. Event handler
C. Subscript
D. Superscript

Correct Answer: B

9. How do you prevent your JavaScript from being displayed by older browser?

A. Place the JavaScript within the <script> tag
B. Place the JavaScript within the header
C. Place the JavaScript within a comment
D. Place the JavaScript within the body

Correct Answer: C

10. JavaScript is

A. A full-featured programming language
B. A limited-featured programming language
C. A version of ASP
D. A version of ASP.NET

Correct Answer: B

11. You reference computer memory by using

A. Operator
B. Variable name
C. Literal value
D. Variable type

Correct Answer: B

12. What tells the browser to do something?

A. Mathematical expression
B. JavaScript expression
C. JavaScript statement
D. Logical expression

Correct Answer: C

13. In the expression 1 + 1, what part of the expression are the numbers?

A. Operand
B. Operator
C. Modulus
D. Incremented

Correct Answer: A

14. In the expression 1 + 1, what part of the expression is the plus sign?

A. Operand
B. Operator
C. Modulus
D. Incremental

Correct Answer: B

15. What is happening in the expression ++a?

A. The value of a is increased by 2.
B. The value of a is increased by 1.
C. The value of a is multiplied by itself.
D. Nothing; this is not a valid JavaScript expression.

Correct Answer: B

16. Evaluate this expression: 7 < 10? ‘You win.’: ‘You lose.’

A. 10
B. You lose.
C. You win.
D. 7

Correct Answer: C

17. What does the && operator do?

A. Evaluates true if expression on its left and right are both true
B. Evaluates true if expression on its left or right is true
C. Evaluates true if neither expression on its left or right is true
D. Combines the expression on its right with the expression on its left

Correct Answer: A

18. True or False: The ++ can be on either the right (c = a++) or left (c = ++a) side of an expression without having any effect on the expression.

A. True
B. False

Correct Answer: B

19. True or False. The x += y expression adds values of x and y and stores the sum in x.

A. True
B. False

Correct Answer: A

20. True or False. The! = operator makes a false true.

A. True
B. False

Correct Answer: A

21. What loop executes statements regardless of whether a condition is true or false?

A. do…while loop
B. while loop
C. for loop
D. for in loop

Correct Answer: A

22. True or False. A switch…case statement cannot have a default case.

A. True
B. False

Correct Answer: B

23. What loop requires the browser to execute statements within the loop at least once?

A. do…while loop
B. while loop
C. for loop
D. for in loop

Correct Answer: A

24. The loop counter in the for loop is used to

A. Increase the expression by 1
B. Increase or decrease the loop counter value by 1
C. Limit the number of statements within the code block
D. Limit the output of statements within the code block

Correct Answer: B

25. True or False. A for loop can become an endless loop.

A. True
B. False

Correct Answer: A

26. What loop is used to step through an unknown number of items on a list?

A. do…while loop
B. while loop
C. for loop
D. for in loop

Correct Answer: D

27. True or False. The default clause is used in an if statement to set default values.

A. True
B. False

Correct Answer: B

28. What is the purpose of else in an if…else statement?

A. Contains statements that are executed if the conditional expression is true
B. Defines another conditional expression the browser evaluates if the first conditional expression is false
C. Contains statements that are executed if the conditional expression is false
D. Used to nest an if statement

Correct Answer: C

29. True or False. You must include an initialize as part of a for loop.

A. True
B. False

Correct Answer: B

30. True or False. The browser can be required to evaluate every case in a switch…case statement event if the criterion matches a case value.

A. True
B. False

Correct Answer: A

31. True or False. This is the first element of the products array: products [1].

A. True
B. False

Correct Answer: B

32. How many elements are there in this array? Products = new Array (‘Soda’,’Beer’,’Pizza’)

A. 2
B. 3
C. 4
D. None

Correct Answer: B

33. What method would you use to create a string from array elements and separate those elements with a hyphen?

A. shift()
B. join()
C. concat()
D. strjoin()

Correct Answer: B

34. What method is used to remove an element from the bottom of an array?

A. push()
B. pop()
C. reverse()
D. shift()

Correct Answer: B

35. What method is used to remove the first element from an array?

A. push()
B. pop()
C. reverse()
D. shift()

Correct Answer: D

36. What method is used to place a new element at the end of an array?

A. push()
B. pop()
C. reverse()
D. shift()

Correct Answer: A

37. True or False. The sort () method only places text in sorted order?

A. True
B. False

Correct Answer: B

38. True or False. The length of an array is equal to the index of the last element of the array.

A. True
B. False

Correct Answer: B

39. True or False. An array element can be used the same way as a variable is used in a JavaScript.

A. True
B. False

Correct Answer: A

40. What method is used to create a new array using elements of another array?

A. slice()
B. div()
C. splice()
D. shift()

Correct Answer: A

41. True or False. A comma must separate arguments in a function defi nition.

A. True
B. False

Correct Answer: A

42. A code block is used in a

A. Function call
B. Function definition
C. Return value
D. Argument

Correct Answer: B

43. The scope of a variable means

A. The size of the variable
B. The data type of the variable
C. The portion of a JavaScript that can access the variable
D. The variable is used as a return value for a function

Correct Answer: C

44. True or False. The statement that calls a function can ignore a value returned by a function.

A. True
B. False

Correct Answer: A

45. A global variable can be accessed

A. Only by functions defined within the JavaScript
B. Only outside of a function
C. Only by the function that defined it
D. From anywhere in the JavaScript

Correct Answer: D

46. A local variable can be accessed

A. Only by functions defined within the JavaScript
B. Only outside of a function
C. Only by the function that defined it
D. From anywhere in the JavaScript

Correct Answer: C

47. True or False. A function can be called by HTML code in a web page.

A. True
B. False

Correct Answer: A

48. True or False. All functions must be defined in the <head> tag.

A. True
B. False

Correct Answer: B

49. True or False. Values passed to a function must correspond to the data type of arguments in the function Definition.

A. True
B. False

Correct Answer: A

50. A variable is out of scope when

A. The statement that calls a function ignores the value returned by the function
B. The variable cannot be accessed by a statement
C. A variable isn’t defined in a function
D. A variable is passed to a function

Correct Answer: B

Other Related Useful Articles: