JavaScript is a fun and flexible programming language. It’s one of the core technologies of web development and can be used on both the front-end and the back-end.
Also Read:
- JavaScript MCQ Questions with Answers – Part 1
- JavaScript MCQ Questions with Answers – Part 2
- JavaScript MCQ Questions with Answers – Part 3
- JavaScript MCQ Questions with Answers – Part 4
- JavaScript MCQ Questions with Answers – Part 5
This article contains 60 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. True or False. A function cannot be called by HTML code in a web page.
A. True
B. False
Correct Answer – B
2. True or False. The statement that calls a function cannot ignore a value returned by a function.
A. True
B. False
Correct Answer – B
3. What method is used to remove the first element from an array?
A. push()
B. pop()
C. reverse()
D. shift()
Correct Answer – D
4. True or False. The ++ can be on either the right (c=a++) or left (c=++a) side without any effect on the expression.
A. True
B. False
Correct Answer – B
5. True or False. A JavaScript must be within the <applet> tag.
A. True
B. False
Correct Answer – B
6. True or False. The browser cannot 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 – B
7. 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
8. 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
9. What is the program that processes a form?
A. Common Gateway Interface
B. Common Program Interface
C. Common Web Server Interface
D. Common Web Server Gateway
Correct Answer – A
10. True or False. All windows do not have to have a menu bar.
A. True
B. False
Correct Answer – A
11. What special character would you use to tell the browser to search all occurrences of a character in a regular expression?
A. *
B. i
C. g
D. a
Correct Answer – C
12. True or False. The index of the last element in the string array is not the same value as the string length.
A. True
B. False
Correct Answer – A
13. 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
14. How do you prevent your JavaScript from being displayed by an 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
15. True or False. This is the second element of the products array: products [1]
A. True
B. False
Correct Answer – A
16. Unicode is
A. A string that contains a numeric value
B. A numeric value that represents characters, numbers, and symbols that can be displayed on the screen
C. The end position used by the substr () method
D. The end position used by the substring () method
Correct Answer – B
17. What loop executes statements regardless whether a condition is true or false?
A. do…while loop
B. while loop
C. for loop
D. for in loop
Correct Answer – A
18. True or False. A dot is used to separate an object name from either a property or a method.
A. True
B. False
Correct Answer – A
19. The this keyword is used to reference the type of browser that is used to view your web page.
A. True
B. False
Correct Answer – B
20. The main purpose of using an external JavaScript file is to
A. Confuse bots
B. Confuse visitors who read the source code
C. Hide Java Scripts
D. Share JavaScript with multiple web pages
Correct Answer – D
21. If you’re working with two vertical frames, how do you make one frame smaller than the other frame?
A. Make one of the rows values smaller than the other
B. Make one of the cols values smaller than the other
C. Make one of the bar values smaller than the other
D. Make one of the bar values larger than the other
Correct Answer – B
22. True or False. All windows must be able to be resized by the visitor.
A. True
B. False
Correct Answer – B
23. True or False. Values of an element can be changed once a person clicks the Submit button.
A. True
B. False
Correct Answer – A
24. 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
25. True or False. A switch…case statement must have a default case.
A. True
B. False
Correct Answer – B
26. What event occurs when an element loses focus?
A. onblur
B. onfocus
C onselect
D. onchange
Correct Answer – A
27. True or False. You call the exec () method of the regular expression object to determine whether one or more characters exists in the text.
A. True
B. False
Correct Answer – A
28. True or False. You reference a specific c object on a document by using the unique name or ID of the object.
A. True
B. False
Correct Answer – A
29. You define empty functions when hiding a JavaScript to
A. Confuse bots
B. Confuse visitors who read the source code
C. Prevent older browsers from displaying an error
D. Prevent new browsers from displaying an error
Correct Answer – C
30. True or False. The order of values passed to a function must correspond to the order of arguments in the function definition.
A. True
B. False
Correct Answer – A
31. True or False. The default clause is used in an if statement to set default values.
A. True
B. False
Correct Answer – B
32. The expiration date is stored in a cookie as
A. GMT string
B. Date data type
C. Digital sequence type
D. Sequential numeric type
Correct Answer – A
33. True or False. Numbers in the expression 1 + 1 are referred to as operands.
A. True
B. False
Correct Answer – A
34. True or False. The length of an array is not equal to the index of the last element of the array.
A. True
B. False
Correct Answer – A
35. True or False. You cannot use a cookie to explore a visitor’s hard disk.
A. True
B. False
Correct Answer – A
36. In the expression 1 + 1, what part of the expression is the +?
A. Operand
B. Operator
C. Modulus
D. Incrementer
Correct Answer – B
37. True or False. A for loop cannot become an endless loop.
A. True
B. False
Correct Answer – B
38. What attribute is used to specify the web page that is loaded into a frame?
A. source
B. src
C. topPage
D. bottomPage
Correct Answer – B
39. Evaluate this expression: 20 > 30? ‘You win.’: ‘You lose.’
A. 20
B. You lose
C. You win
D. 30
Correct Answer – B
40. True or False. You hide the borders of a frame by using frameborder=”0″
A. True
B. False
Correct Answer – A
41. What is it called when a person changes information on a form?
A. Event
B. Reaction
C. Rollover
D. Mouse rollover
Correct Answer – A
42. True or False. The browser automatically replaces a rollover image with the original image when the mouse cursor moves away from an object.
A. True
B. False
Correct Answer – B
43. Document. Write () is an example of a(n)
A. Object
B. Method
C. Property
D. Variable
Correct Answer – B
44. True or False. An external JavaScript fi le is stored on a web server in the same domain as the calling page.
A. True
B. False
Correct Answer – A
45. A JavaScript function can instruct the browser to submit a form by
A. Returning a false to the onsubmit attribute of the form
B. Returning a true to the onsubmit attribute of the form
C. Returning a true to the submit attribute of the form
D. None of the above
Correct Answer – B
46. True or False. Banners are not typically displayed on the status bar.
A. True
B. False
Correct Answer – A
47. True or False. You reference an external JavaScript fi le in the src attribute of the <script> tag.
A. True
B. False
Correct Answer – A
48. You can dynamically change a menu by
A. Creating an array and then using new Option to assign array elements to the Options menu
B. Creating an array and then using onload to assign array elements to the Options menu
C. Creating an array and then using onchange to assign array elements to the Options menu.
D. None of the above
Correct Answer – A
49. True or False. The current date and time of the Date object must be converted to a string when used on the status bar.
A. True
B. False
Correct Answer – A
50. True or False. When the value of the selected menu option is null, no value was assigned to the value attribute of the option.
A. True
B. False
Correct Answer – A
51. True or False. A child window can change the content of another child window if they are on different domains.
A. True
B. False
Correct Answer – B
52. You validate a menu selection by using the
A. onerr attribute
B. onstorage attribute
C. onvalidate attribute
D. onsubmit attribute
Correct Answer – D
53. True or False. Only GIF files can be displayed as a banner.
A. True
B. False
Correct Answer – B
54. True or False. You do not set options for a dynamic menu in response to an onchange event.
A. True
B. False
Correct Answer – B
55. True or False. Multiple rotating banners can be shown on a web page at the same time.
A. True
B. False
Correct Answer – A
56. True or False. DHTML has no relationship to CSS and JavaScript.
A. True
B. False
Correct Answer – B
57. The standard for DHTML is defined in
A. HTML 4.0
B. HTML 3.0
C. HTML 4.5
D. None of the above
Correct Answer – A
58. You apply a class by
A. Assigning the class name to the class attribute
B. Assigning the class name to the id attribute
C. Calling the class name from anywhere in the web page
D. All of the above
Correct Answer – A
59. True or False. JavaScript replaces DHTML
A. True
B. False
Correct Answer – B
60. Classes are defined within
A. <div>
B. <style>
C. <p>
D. None of the above
Correct Answer – B
You may also like:- 260 One-Liner Information Security Questions and Answers for Fast Learning
- Top 20 HTML5 Interview Questions with Answers
- 80 Most Important Network Fundamentals Questions With Answers
- 100 Most Important SOC Analyst Interview Questions
- Top 40 Cyber Security Questions and Answers
- Top 10 React JS Interview Theory Questions and Answers
- CISSP – Practice Test Questions – 2024 – Set 20 (53 Questions)
- Part 2: Exploring Deeper into CCNA – Wireless (145 Practice Test Questions)
- Part 1: Mastering CCNA – Wireless (145 Practice Test Questions)
- [1z0-1085-20] Oracle Cloud Infrastructure Foundations 2020 Associate MCQ Questions – Part 3