JavaScript, often abbreviated JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS.
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 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. True or False. The first character of a string array is string [1].
A. True
B. False
Correct Answer – B
2. A float is
A. An integer
B. A whole number
C. A decimal value
D. A Unicode number
Correct Answer – C
3. What method would you use to divide a string of data delimited by a comma into an array of data?
A. parse Float()
B. split()
C. parseInt()
D. charCodeAt()
Correct Answer – B
4. The end position argument in the substring () method indicates what?
A. The position of the last character that is copied into the substring
B. The position of the first character that is copied into the substring
C. The position of the character following the last character that is copied into the substring
D. The position of the character preceding the last character in the substring
Correct Answer – D
5. The second argument in the substr () method indicates what?
A. The position of the last character that is copied into the substring
B. The number of characters that are to be copied from the string to the substring
C. The position of the character preceding the last character that is copied into the substring
D. The position of the character preceding the last character in the substring
Correct Answer – B
6. What is the length value of a string object?
A. The total number of characters in the string
B. The index of the last character in the string
C. The length of the string minus spaces
D. The length of the string minus trailing spaces
Correct Answer – A
7. True or False. The index of the last element in the string array is the same value as the string length.
A. True
B. False
Correct Answer – B
8. True or False. The parseInt () method cannot be used with a mixed number (whole number and decimal).
A. True
B. False
Correct Answer – B
9. True or False. A delimiter string is used by the split () method to create an array of data elements.
A. True
B. False
Correct Answer – A
10. 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
11. True or False. A check box is an element of a form.
A. True
B. False
Correct Answer – A
12. 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
13. What event occurs when an element comes into focus?
A. onblur
B. onfocus
C. onselect
D. onchange
Correct Answer – B
14. What event occurs when an element loses focus?
A. onblur
B. onfocus
C. onselect
D. onchange
Correct Answer – A
15. What event occurs when a user highlights text in a text field?
A. onblur
B. onfocus
C. onselect
D. onchange
Correct Answer – C
16. What is the purpose of the with statement?
A. Identifies variables that are used in a script
B. Identifies elements that are used in a script
C. Identifies the full document path
D. Identifies the current element
Correct Answer – C
17. True or False. All attributes except the name attribute can be changed by a JavaScript.
A. True
B. False
Correct Answer – B
18. True or False. Values of an element cannot be changed once a user clicks the Submit button.
A. True
B. False
Correct Answer – B
19. True or False. A JavaScript function can only change attributes of an element that calls the JavaScript function.
A. True
B. False
Correct Answer – B
20. An intrinsic function
A. Must be defined in the <head> tag
B. Must be defined in the <body> tag
C. Must be defined by the programmer either to submit or reset the form
D. Is not defined by the programmer
Correct Answer – D
21. True or False. You cannot delete a cookie.
A. True
B. False
Correct Answer – B
22. A cookie takes the format of a
A. Pair-name value
B. Pair-value name
C. Value-name pair
D. Name-value pair
Correct Answer – D
23. The best time to read a cookie is
A. onblur
B. onload
C. onselect
D. onchange
Correct Answer – B
24. The expiration date is stored in a cookie as
A. A GMT string
B. A Date data type
C. A digital sequence type
D. A sequential numeric type
Correct Answer – A
25. The best time to create a cookie is
A. onblur
B. onload
C. Any time it makes sense to do so while a visitor is visiting your web site
D. onchange
Correct Answer – C
26. A cookie is
A. A variable
B. A Date variable
C. A text variable
D. An object
Correct Answer – D
27. True or False. You can use a cookie to explore a visitor’s hard disk.
A. True
B. False
Correct Answer – B
28. True or False. Your JavaScript actually writes a cookie to a visitor’s hard disk if you set an expiration date for the cookie.
A. True
B. False
Correct Answer – B
29. True or False. The address of your web server is included in a cookie.
A. True
B. False
Correct Answer – A
30. Information in a cookie identifies
A. The person who is visiting your web site
B. The computer used by the person who is visiting your web site
C. The Internet service provider used by the person who is visiting your web site
D. The visitor’s browser
Correct Answer – B
31. True or False. The window. Open () method requires arguments to open a new window.
A. True
B. False
Correct Answer – B
32. You can position a new window on screen by setting the
A. width and height properties
B. left and top properties
C. resizable property
D. status property
Correct Answer – B
33. You can open a new window on top of other windows by calling
A. upper()
B. up()
C. focus()
D. next()
Correct Answer – C
34. You determine the resolution of the screen by accessing
A. left and top properties
B. resolution property
C. width and height properties
D. pixel Depth property
Correct Answer – C
35. You scroll a window by calling
A. goto
B. down or up
C. down
D. scroll To()
Correct Answer – D
36. You can create a new window that does not contain the standard browser buttons by setting
A. scrollbars=1
B. directories=1
C. directories=0
D. scrollbars=0
Correct Answer – C
37. True or False. All windows must have a menu bar.
A. True
B. False
Correct Answer – B
38. True or False. All windows must have the standard browser toolbar.
A. True
B. False
Correct Answer – B
39. True or False. Displaying too many new windows in the same session can prevent the user from doing any work.
A. True
B. False
Correct Answer – A
40. You can prevent a person from resizing your new window by
A. Setting resizable to 1
B. Setting resizable to 0
C. Setting the menubar to 1
D. Setting the menubar to 0
Correct Answer – B
41. True or False. A regular expression begins with the special character \b.
A. True
B. False
Correct Answer – B
42. Which special character is used to tell the browser to start at the beginning of a string?
A. $
B. *
C. ^
D. []
Correct Answer – C
43. What special character would you use to specify any nondigit?
A. \d
B. \D
C. $
D. $*
Correct Answer – B
44. What special character would use you to tell the browser to search all occurrences of a character?
A. *
B. i
C. g
D. a
Correct Answer – C
45. What special character do you use to search for a whitespace character?
A. \s
B. \S
C. s
D. S
Correct Answer – A
46. What special character do you use to search for any letter, number, or the underscore?
A. \w
B. \W
C. w
D. W
Correct Answer – A
47. 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
48. True or False. A regular expression cannot be used to reformat text.
A. True
B. False
Correct Answer – B
49. True or False. You cannot insert literal characters into a regular expression.
A. True
B. False
Correct Answer – B
50. What regular expression property contains text that precedes characters that match the regular expression?
A. *Context
B. left Context
C. Context*
D. context Left
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