JavaScript MCQ

391 Questions

Soopro Pathshala – JavaScript Multiple Choice Questions

Question 1. Which of the following methods can be used to display data in Javascript?
a) confirm()
b) console.log()
c) alert()
d) all of above
Answer: (d) all of above
Question 2. How can a datatype be declared to be a constant type?
a) cons
b) const
c) c
d) constant
Answer: (b) const
Question 3. What keyword is used to check whether a given property is valid or not?
a) is
b) in
c) exists
d) default
Answer: (b) in
Question 4. How many way to link javascript __
a) 2
b) 4
c) 3
d) 1
Answer: (c) 3
Question 5. can var, const, or let all keyword use in javascript.
a) Yes
b) No
c) only let or const
d) only var or let
Answer: (a) Yes
Question 6. In javaScript this is sign of [{}]
a) object
b) array
c) object array
d) array object
Answer: (d) array object
Question 7. How to declare function in javascript.
a) using function keyword
b) using var keyword
c) using new keyword
d) using const keyword
Answer: (a) using function keyword
Question 8. How many types of loop work in javaScript?
a) 2
b) 3
c) 4
d) 6
Answer: (c) 4
Question 9. In which year javaScript lunched?
a) 1954
b) 1994
c) 1995
d) 1987
Answer: (c) 1995
Question 10. Which one is view engine of google chrome?e
a) V8
b) Spider
c) Spider monkey
d) Chrome
Answer: (a) V8
Question 11. A javaScript file save with __extension
a) .json
b) .js
c) .script
d) .ts
Answer: (b) .js
Question 12. Who is developer of JS?
a) Tim Berner Lee
b) Brendan Eich
c) James gosling
d) none of these
Answer: (b) Brendan Eich
Question 13. How to define multi lines comments in JavaScript?
a) //
b) /* Hello World */
c) %Hello World%
d) #Hello World#
Answer: (b) /* */
Question 14. In switch case use__?
a) Return
b) Break
c) both a and b
d) none of the above
Answer: (c) both a and b
Question 15. What is extension of JavaScript?
a) .js
b) .java
c) .javascript
d) none of the above
Answer: (a) .js
Question 16. in Javascript alert(),cofirm(), and prompt() are message boxes
a) yes
b) no
c) may be
d) cant say
Answer: (a) yes
Question 17. In javaScript "=== "operator defines what?
a) non inentical
b) it compare value and data type both
c) unequal
d) not equal to
Answer: (b) it compare value and data type both
Question 18. Among of the following is a language of javascript?
a) text/javascript
b) text/ECMAScript
c) text/VBScript
d) JavaScript/VBScript
Answer: (a) text/javascript
Question 19. Which of the following is the property that is triggered in response to JS errors?
a) onclick
b) onerror
c) onmessage
d) onexception
Answer: (b) onerror
Question 20. JavaScript is ____language
a) Application
b) Scripting
c) Programming
d) None of these
Answer: (b) Scripting
Question 21. Which company developed JavaScript?
a) IBM
b) Bell Labs
c) Netscape
d) Sun Microsystems
Answer: (c) Netscape
Question 22. JavaScript is __ Side Scripting Language.
a) ISP
b) Server
c) Client
d) None of the above
Answer: (c) Client
Question 23. Which of the following is not JavaScript Data Types?
a) Undefined
b) Number
c) Boolean
d) Float
Answer: (d) Float
Question 24. Which of the following code creates an object?
a) var book=Object();
b) var book=new Object();
c) var book=new Book();
d) var book=OBJECT();
Answer: (b) var book=new Object();
Question 25. JavaScript is designed for the following purpose:
a) To style HTML pages
b) To execute Queries related to databases on a server
c) To add interactivity to html pages
d) all of the above
Answer: (b) To execute queries related to databases on a server
Question 26. To include external JS code inside an HTML document which attribute is used?
a) src
b) link
c) script
d) href
Answer: (b) link
Question 27. Which function in js used to convert text to upper case?
a) toLocalUpperCase()
b) toString()
c) substring()
d) toUpperCase()
Answer: (d) toUpperCase()
Question 28. Which of the following is not considered a JavaScript operator?
a) this
b) new
c) typeof
d) delete
Answer: (d) delete
Question 29. Comments in JS are ignored by___
a) Browser
b) JVM
c) Operating System
d) Compiler
Answer: (a) Browser
Question 30. "+=" operator can operate on following data values.
a) all options
b) string
c) integer
d) float
Answer: (a) all options
Question 31. How many ways to call function in JavaScript?
a) call by value and call by reference
b) call by function
c) call by data value
d) call by compiler
Answer: (a) call by value and call by reference
Question 32. How many types of data type in javaScript.
a) 1
b) 2
c) 3
d) 4
Answer: (b) 2
Question 33. How many types of function in javaScript.
a) user define
b) user define or pre define
c) pre define
d) none of the above
Answer: (b) user define or pre define
Question 34. Which is JavaScript reserved keywords?
a) try
b) catch
c) function
d) all of above
Answer: (d) all of above
Question 35. unary operator work on__?
a) single operand
b) two operands
c) two or more than two operands
d) none of above
Answer: (a) single operand
Question 36. How many ways to define user defined function?
a) 1
b) 2
c) 3
d) 4
Answer: (d) 4
Question 37. When an operator’s value is NULL, the typeof returned by the unary operator is____
a) Boolean
b) Undefine
c) Object
d) Integer
Answer: (c) object
Question 38. What is anonymous function in javaScript?
a) A function without any name
b) A special function with name
c) Data type
d) none of above
Answer: (a) a function without any name
Question 39. getElementsByClassName() Returns____
a) can access html elements by class name
b) given name
c) given id
d) both a and b
Answer: (a) can access html elements by class name
Question 40. How many types of validation?
a) client side
b) server side
c) both a and b
d) none of above
Answer: (c) both a and b
Question 41. It was initially named ___?
a) Mocha
b) Live script
c) Type script
d) none of above
Answer: (a) Mocha
Question 42. Which javascript engine developed by Google for Chrome and used in Node JS?
a) V8
b) Spider Monkey
c) JavaScript Core
d) none of above
Answer: (a) V8
Question 43. Which javascript engine used in Firefox?
a) V8
b) Spider Monkey
c) JavaScript Core
d) none of above
Answer: (b) Spider Monkey
Question 44. A__ is single or multiple lines, which give some information about the current program.
a) Comment
b) script
c) both a and b
d) none of above
Answer: (a) Comment
Question 45. ___ are reserved words in JavaScript, which cannot be used as variable names or function names.
a) variable
b) comment
c) keyword
d) none of above
Answer: (c) keyword
Question 46. ______Display a popup box with the specified message with the OK button.
a) alert(message)
b) confirm()
c) prompt()
d) none of above
Answer: (a) alert(message)
Question 47. ______Display a popup box with the specified message with OK and Cancel buttons.
a) alert(message)
b) confirm()
c) prompt()
d) none of above
Answer: (b) confirm()
Question 48. ______Display a popup box to take the user's input with the OK and Cancel buttons.
a) alert(message)
b) confirm()
c) prompt(message, default value)
d) none of above
Answer: (c) prompt(message, default value)
Question 49. ______means anything that can vary.
a) script
b) style
c) variable
d) none of above
Answer: (c) variable
Question 50. _____is used to declare variables since JavaScript was created
a) var keyword
b) let keyword
c) const keyword
d) none of above
Answer: (a) var keyword
Question 51. _____ removes the confusion and error of var. It is the new and recommended way of declaring variables in JavaScript.
a) var keyword
b) let keyword
c) const keyword
d) none of above
Answer: (b) let keyword
Question 52. ______ is used to declare a constant variable that cannot be changed once assigned a value.
a) var keyword
b) let keyword
c) const keyword
d) none of above
Answer: (c) const keyword
Question 53. Variables declared out of any function are called ___
a) local variable
b) global variable
c) const keyword
d) none of above
Answer: (b) global keyword
Question 54. Variables declared inside of any function are called ___
a) local variable
b) global variable
c) const keyword
d) none of above
Answer: (a) local variable
Question 55. the ___ are used to combine two or more conditions
a) logical operators
b) comparison oprators
c) assignment operators
d) none of above
Answer: (a) logical operators
Question 56. The ______ starts with conditional expression followed by the ? operator
a) Ternary operator
b) comparison oprator
c) assignment operator
d) none of above
Answer: (a) Ternary operator
Question 57. A ____ is a primitive data type that is used for textual data
a) string
b) var
c) let
d) none of above
Answer: (a) string
Question 58. The ____ type is a numeric primitive type that can store integers with arbitrary precision.
a) Big int
b) int
c) let
d) none of above
Answer: (a) Big int
Question 59. The ____ is a primitive data type in JavaScript.
a) boolean
b) var
c) let
d) none of above
Answer: (a) boolean
Question 60. An ___ is a non-primitive, structured data type in JavaScript.
a) boolean
b) object
c) let
d) none of above
Answer: (b) object
Question 61. JavaScript ____ can be treated like a character array
a) boolean
b) object
c) string
d) none of above
Answer: (c) string
Question 62. Which property return the length of string?
a) length
b) charat
c) var
d) none of above
Answer: (a) length
Question 63. The ____ numbers must start with 0b or 0B followed by 0 or 1.
a) binary
b) octal
c) exponential
d) none of above
Answer: (a) binary
Question 64. The ____ numbers must start with zero and the lower or upper letter X, 0x or 0X
a) binary
b) hexadecimal
c) exponential
d) none of above
Answer: (b) hexadecimal
Question 65. The _____ numbers must start with zero and the lower or upper letter O, 0o or 0O.
a) binary
b) hexadecimal
c) octal
d) none of above
Answer: (c) octal
Question 66. The ______ is a primitive data type in JavaScript. It can have only two values: true or false
a) binary
b) boolean
c) octal
d) none of above
Answer: (b) boolean
Question 67. JavaScript ___ is a special type of variable, which can store multiple values using a special syntax.
a) int
b) boolean
c) array
d) none of above
Answer: (c) array
Question 68. Which function Adds one or more elements at the end of an array and returns the new length of the array.
a) push()
b) pop()
c) map()
d) none of above
Answer: (a) push()
Question 69. Which function Reverses the elements of an array. Element at last index will be first and element at 0 index will be last.
a) push()
b) pop()
c) reverse()
d) none of above
Answer: (c) reverse()
Question 70. Which funtion Removes the first element from an array and returns that element.
a) push()
b) shift()
c) reverse()
d) none of above
Answer: (b) shift()
Question 71. JavaScript includes _____ loop to execute code repeatedly till it satisfies a specified condition.
a) while
b) for
c) do while
d) none of above
Answer: (a) while
Question 72. The ____ loop is similar to while loop the only difference is it evaluates condition expression after the execution of code block
a) while
b) for
c) do while
d) none of above
Answer: (c) do while
Question 73. The ____ loop is similar to while loop the only difference is it evaluates condition expression after the execution of code block
a) while
b) for
c) do while
d) none of above
Answer: (c) do while
Question 74. Variables declared outside of any function become _____ variables.
a) local
b) global
c) both
d) none of above
Answer: (b) global
Question 75. Variables declared inside any function with var keyword are called ____ variables
a) local
b) global
c) both
d) none of above
Answer: (a) local
Question 76. ______ are the basic building block of JavaScript
a) function
b) variables
c) class
d) none of above
Answer: (a) function
Question 77. ______ are the basic building block of JavaScript
a) function
b) variables
c) class
d) none of above
Answer: (a) function
Question 78. In JavaScript, a function can have one or more inner functions is called______
a) nested function
b) anonymous function
c) cant say
d) none of above
Answer: (a) nested
Question 79. In JavaScript, a function can have one or more inner functions is called______
a) nested function
b) anonymous function
c) cant say
d) none of above
Answer: (a) nested function
Question 80. How many scopes are there in javascript?
a) 2
b) 3
c) 1
d) none of above
Answer: (a) 2
Question 81. _____ is a special method for initializing objects.
a) constructor
b) method
c) variable
d) none of above
Answer: (a) constructor
Question 82. ____ is an important concept in object oriented programming. In the classical inheritance, methods from base class get copied into derived class.
a) inheritance
b) polymorphism
c) class
d) none of above
Answer: (a) inheritance
Question 83. When an operator’s value is NULL, the typeof returned by the unary operator is:
a) Boolean
b) Undefined
c) object
d) integer
Answer: (c) object
Question 84. Which function is used to serialize an object into a JSON string in Javascript?
a) stringify()
b) parse()
c) convert
d) none of these
Answer: (a) stringify()
Question 85. Which of the following are closures in Javascript?
a) variables
b) functions
c) objects
d) all of the above
Answer: (d) all of the above
Question 86. Which of the following are not server-side Javascript objects?
a) Date
b) FileUpload
c) Function
d) all of the above
Answer: (d) all of the above
Question 87. Which of the following is not a Javascript framework?
a) Node
b) Vue
c) React
d) Casandara
Answer: (d) all of the above
Question 88. Which of the following keywords is used to define a variable in Javascript?
a) var
b) let
c) both a and b
d) none of the above
Answer: (c) both a and b
Question 89. Which of the following methods can be used to display data in some form using Javascript?
a) document.write()
b) console.log()
c) window.alert()
d) all of the above
Answer: (d) all of the above
Question 90. Which of the following methods is used to access HTML elements using Javascript?
a) getElementById()
b) getElementsByClassName()
c) both a and b
d) none of the above
Answer: (c) both a and b
Question 91. What does JavaScript primarily run in?
a) Database
b) Browser
c) Compiler
d) Printer
Answer: (b) Browser
Question 92. Which symbol is used for comments in JavaScript?
a) ##
b) //
c) %%
d) @@
Answer: (b) //
Question 93. Which keyword is used to declare a variable?
a) var
b) int
c) string
d) define
Answer: (a) var
Question 94. Which company developed JavaScript?
a) Microsoft
b) Netscape
c) Google
d) IBM
Answer: (b) Netscape
Question 95. Which keyword is used for constant variables?
a) let
b) var
c) const
d) fixed
Answer: (c) const
Question 96. Which operator is used for strict equality?
a) ==
b) =
c) ===
d) !=
Answer: (c) ===
Question 97. What is the output of typeof null?
a) object
b) null
c) Undefined
d) string
Answer: (a) object
Question 98. Which method displays output in browser console?
a) print()
b) echo()
c) console.log()
d) write()
Answer: (c) console.log()
Question 99. Which function is used to display a popup message?
a) prompt()
b) alert()
c) confirm()
d) popup()
Answer: (b) alert()
Question 100. Which function is used to display a popup message?
a) prompt()
b) alert()
c) confirm()
d) popup()
Answer: (b) alert()
Question 101. JavaScript is a ______ language.
a) styling
b) scripting
c) markup
d) database
Answer: (b) scripting
Question 102. Which symbol is used to end statements?
a) :
b) ;
c) #
d) ?
Answer: (b) ;
Question 103. Which data type is NOT primitive?
a) Number
b) String
c) Object
d) Boolean
Answer: (c) Object
Question 104. Which method converts JSON into object?
a) JSON.parse()
b) JSON.stringify()
c) JSON.convert()
d) JSON.object()
Answer: (a) JSON.parse()
Question 105. Which loop runs at least once?
a) for
b) while
c) do...while
d) foreach
Answer: (c) do...while
Question 106. What is the output of 2 + "2"?
a) 4
b) 22
c) Error
d) Undefined
Answer: (b) 22
Question 107. Which keyword is block scoped?
a) var
b) let
c) both
d) none
Answer: (b) let
Question 108. Which method adds element at end of array?
a) push()
b) pop()
c) shift()
d) slice()
Answer: (a) push()
Question 109. Which method removes last array element?
a) shift()
b) delete()
c) pop()
d) splice()
Answer: (c) pop()
Question 110. Which operator is used for exponentiation?
a) ^
b) **
c) %%
d) //
Answer: (b) **
Question 111. Which method joins array elements into string?
a) concat()
b) join()
c) merge()
d) split()
Answer: (b) join()
Question 112. Which keyword refers to current object?
a) self
b) object
c) this
d) current
Answer: (c) this
Question 113. What is the default value of uninitialized variable?
a) 0
b) null
c) Undefined
d) false
Answer: (c) Undefined
Question 114. Which event occurs when user clicks mouse?
a) onmouseover
b) onclick
c) onload
d) onchange
Answer: (b) onclick
Question 115. Which method converts object to JSON string?
a) JSON.parse()
b) JSON.stringify()
c) JSON.object()
d) JSON.convert()
Answer: (b) JSON.stringify()
Question 116. Which array method removes first element?
a) pop()
b) push()
c) shift()
d) unshift()
Answer: (c) shift()
Question 117. Which method adds element at beginning of array?
a) push()
b) shift()
c) splice()
d) unshift()
Answer: (d) unshift()
Question 118. JavaScript file extension is?
a) .java
b) .js
c) .json
d) .jsx
Answer: (b) .js
Question 119. Which method writes content to webpage?
a) document.write()
b) window.print()
c) console.log()
d) innerHTML
Answer: (a) document.write()
Question 120. Which method converts string to integer?
a) parseint()
b) Number()
c) Integer()
d) Both a and b
Answer: (d) Both a and b
Question 121. Which method converts string to integer?
a) parseInt()
b) Number()
c) Integer()
d) Both a and b
Answer: (d) Both a and b
Question 122. Which operator checks both value and type?
a) ==
b) ===
c) =
d) !=
Answer: (b) ===
Question 123. Which function takes user input?
a) alert()
b) prompt()
c) input()
d) confirm()
Answer: (b) prompt()
Question 124. Which statement is used for decision making?
a) if
b) loop
c) array
d) object
Answer: (a) if
Question 125. Which loop is best for arrays?
a) for
b) while
c) for..of
d) do...while
Answer: (c) for..of
Question 126. What is output of Boolean(0)?
a) true
b) false
c) undefined
d) null
Answer: (b) false
Question 127. Which method finds array length?
a) size()
b) count()
c) length
d) total()
Answer: (c) length
Question 128. Which keyword stops loop?
a) continue
b) stop
c) break
d) exit
Answer: (c) break
Question 129. Which method is used to remove spaces from string?
a) trim()
b) cut()
c) remove()
d) strip()
Answer: (a) trim()
Question 130. Which keyword skips current loop iteration?
a) skip
b) pass
c) continue
d) next
Answer: (c) continue
Question 131. What is output of typeof "Hello"?
a) text
b) string
c) object
d) char
Answer: (b) string
Question 132. Which object represents browser window?
a) screen
b) navigator
c) document
d) window
Answer: (d) window
Question 133. Which method selects element by ID?
a) getElementById()
b) querySelectorAll()
c) getElements()
d) selectById()
Answer: (a) getElementById()
Question 134. Which method is used to delay execution?
a) setDelay()
b) setTimeOut()
c) wait()
d) timeout()
Answer: (b) setTimeOut()
Question 135. Which method repeats execution continuously?
a) setRepeat()
b) setTimeOut()
c) setInterval()
d) repeat()
Answer: (c) setInterval()
Question 136. Which operator is used for logical AND?
a) &&
b) ||
c) !
d) &
Answer: (a) &&
Question 137. Which operator is used for logical OR?
a) &&
b) ||
c) !!
d) %%
Answer: (b) ||
Question 138. Which keyword is used in switch statement?
a) select
b) case
c) choose
d) check
Answer: (b) case
Question 139. Which statement handles errors?
a) error-catch
b) try-catch
c) final
d) throw-error
Answer: (b) try-catch
Question 140. Which keyword throws custom error?
a) error
b) catch
c) throw
d) exception
Answer: (c) throw
Question 141. What is DOM full form?
a) Document Object Model
b) Data Object Management
c) Digital Order Model
d) Document Order Module
Answer: (a) Document object Model
Question 142. Which method converts string to lowercase?
a) lower()
b) toLowerCase()
c) lowercase()
d) small()
Answer: (b) toLowerCase()
Question 143. Which method converts string to uppercase?
a) upper()
b) capitialize()
c) toUpperCase()
d) big()
Answer: (c) toUpperCase()
Question 144. Which array method creates new array?
a) map()
b) push()
c) pop()
d) shift()
Answer: (a) map()
Question 145. Which array method filters elements?
a) filter()
b) reduce()
c) map()
d) search()
Answer: (a) filter()
Question 146. Which array method returns single value?
a) reduce()
b) map()
c) filter()
d) push()
Answer: (a) reduce()
Question 147. Which keyword is used in ES6 for importing modules?
a) include
b) require
c) import
d) using
Answer: (c) import
Question 148. Which keyword exports module?
a) share
b) export
c) send
d) public
Answer: (b) export
Question 149. Which method checks if array includes value?
a) contains()
b) includes()
c) has()
d) exist()
Answer: (b) includes()
Question 150. Which symbol is used for arrow functions?
a) =>
b) ->
c) ==
d) <>
Answer: (a) =>
Question 151. What is output of typeof []?
a) array
b) object
c) list
d) undefined
Answer: (b) object
Question 152. Which method combines arrays?
a) merge()
b) join()
c) concat()
d) add()
Answer: (c) concat()
Question 153. Which method extracts part of array?
a) splice()
b) cut()
c) slice()
d) split()
Answer: (c) slice()
Question 154. Which method converts string into array?
a) split()
b) join()
c) concat()
d) trim()
Answer: (a) split()
Question 155. Which event occurs after page loads?
a) onclick
b) onsubmit
c) onload
d) onchange
Answer: (c) onload
Question 156. Which method prevents default behavior?
a) stopDefault()
b) preventDefault()
c) blockDefault()
d) returnFalse()
Answer: (b) preventDefault()
Question 157. Which keyword creates class in ES6?
a) object
b) function
c) class
d) constructor
Answer: (c) class
Question 158. Which method is constructor of class?
a) build()
b) constructor()
c) class
d) constructor
Answer: (c) class
Question 159. Which keyword inherits class?
a) inherits
b) extends
c) super
d) implement
Answer: (b) extends
Question 160. Which keyword calls parent constructor?
a) parent
b) this
c) super
d) base
Answer: (c) super
Question 161. JavaScript is case ______.
a) insensitive
b) sensitive
c) ignored
d) fixed
Answer: (b) sensitive
Question 162. Which method rounds number down?
a) Math.ceil()
b) Math.floor()
c) Math.round()
d) Math.random()
Answer: (b) Math.floor()
Question 163. Which method rounds number up?
a) Math.ceil()
b) Math.floor()
c) Math.round()
d) Math.min()
Answer: (a) Math.ceil()
Question 164. Which method generates random number?
a) Math.random()
b) Math.generate()
c) random()
d) rand()
Answer: (a) Math.random()
Question 165. Which operator is ternary operator?
a) ::
b) ?:
c) =>
d) %%
Answer: (b) ?:
Question 166. Which method removes item from specific position?
a) splice()
b) slice()
c) shift()
d) pop()
Answer: (a) splice()
Question 167. Which statement is used for multiple conditions?
a) switch
b) if
c) loop
d) break
Answer: (a) switch
Question 168. Which object stores key-value pairs?
a) Array
b) String
c) Object
d) Number
Answer: (c) Object
Question 169. Which method checks array condition?
a) every()
b) push()
c) pop()
d) join()
Answer: (a) every
Question 170. Which method checks at least one condition?
a) every()
b) some()
c) map()
d) reduce()
Answer: (b) some()
Question 171. Which symbol is used for NOT operator?
a) &&
b) ||
c) !
d) !=
Answer: (c) !
Question 172. Which object handles dates?
a) Time
b) calendar
c) Date
d) Day
Answer: (c) Date
Question 173. Which method gets current year?
a) getYear()
b) currentYear()
c) getFullYear()
d) year()
Answer: (c) getFullYear()
Question 174. Which method converts value to string?
a) toString()
b) string()
c) convert()
d) stringify()
Answer: (a) toString()
Question 175. Which method finds maximum value?
a) Math.high()
b) Math.max()
c) max()
d) highest()
Answer: (b) Math.max()
Question 176. Which method finds minimum value?
a) Math.min()
b) Math.low()
c) minimum()
d) low()
Answer: (a) Math.min()
Question 177. Which storage keeps data permanently in browser?
a) sessionStorage
b) localStorage
c) cookieStorage
d) tempStorage
Answer: (b) localStorage
Question 178. Which storage clears after browser closes?
a) permanentStorage
b) localStorage
c) sessionStorage
d) cookie
Answer: (c) sessionStorage
Question 179. Which method adds HTML content inside element?
a) innerHTML
b) outerHTML
c) textHTML
d) htmlText
Answer: (a) innerHTML
Question 180. Which framework is based on JavaScript?
a) Laravel
b) Django
c) React
d) Flask
Answer: (c) React
Question 181. Which method converts JSON string into JavaScript object?
a) JSON.object()
b) JSON.parse()
c) JSON.convert()
d) JSON.stringify()
Answer: (b) JSON.parse()
Question 182. Which keyword declares a variable that cannot be reassigned?
a) let
b) var
c) const
d) static
Answer: (c) const
Question 183. Which method is used to find index of an array element?
a) find()
b) indexOf()
c) search
d) locate()
Answer: (b) indexOf
Question 184. Which method removes all child nodes from an element?
a) deleteChild()
b) removeAll()
c) innerHTML=""
d) clearNode()
Answer: (c) innerHTML=""
Question 185. What is the output of 5 == "5"?
a) false
b) true
c) undefined
d) error
Answer: (b) true
Question 186. What is the output of 5 === "5"?
a) true
b) false
c) undefined
d) error
Answer: (b) false
Question 187. Which keyword is used to define asynchronous function?
a) sync
b) async
c) await
d) defer
Answer: (b) async
Question 188. Which keyword waits for Promise result?
a) async
b) hold
c) await
d) pause
Answer: (c) await
Question 189. Which object is used for mathematical operations?
a) Calc
b) Number
c) Math
d) Numeric
Answer: (c) Math
Question 190. Which method converts number into fixed decimal string?
a) toDecimal()
b) toFixed()
c) decimal()
d) fix()
Answer: (b) toFixed()
Question 191. Which method checks whether value is an array?
a) isArray()
b) Array.isArray()
c) checkArray()
d) typeof
Answer: (b) Array.isArray()
Question 192. Which symbol is used for single-line comments?
a)
b) //
c) /**/
d) ##
Answer: (b) //
Question 193. Which symbol is used for multi-line comments?
a) ####
b)
c) /**/
d) %%%%
Answer: (c) /**/
Question 194. Which event occurs when form is submitted?
a) onclick
b) onsubmit
c) onchange
d) onload
Answer: (b) onsubmit
Question 195. Which method removes specific element from DOM?
a) remove()
b) delete()
c) erase()
d) cut()
Answer: (a) remove()
Question 196. Which operator is used for addition assignment?
a) +=
b) =+
c) ++
d) add=
Answer: (a) +=
Question 197. Which operator increments value by 1?
a) --
b) ++
c) +=
d) **
Answer: (b) ++
Question 198. Which operator decrements value by 1?
a) ++
b) -=
c) --
d) **
Answer: (c) --
Question 199. Which method executes function for each array element?
a) map()
b) filter()
c) forEach()
d) every()
Answer: (c) forEach()
Question 200. Which function converts string into floating number?
a) parseInt()
b) float()
c) parseFloat()
d) NumberFloat()
Answer: (c) parseFloat()
Question 201. What is the output of typeof NaN?
a) undefined
b) object
c) number
d) string
Answer: (c) number
Question 202. Which method merges two objects?
a) Object.assign()
b) Object.merge()
c) Object.join()
d) mergeObject()
Answer: (a) Object.assign()
Question 203. Which loop is used to iterate object properties?
a) for...in
b) for...of
c) while
d) do..while
Answer: (a) for..in
Question 204. Which loop iterates iterable objects like arrays?
a) for...in
b) for...of
c) while
d) loop...of
Answer: (b) for..of
Question 205. Which method creates a new Promise?
a) Promise.new()
b) new Promise()
c) Promise.create()
d) create Promise
Answer: (b) new Promise()
Question 206. Which method handles successful Promise result?
a) catch()
b) then()
c) finally()
d) resolve()
Answer: (b) then()
Question 207. Which method handles Promise errors?
a) error()
b) reject()
c) catch()
d) fail()
Answer: (c) catch()
Question 208. Which method always runs after Promise completion?
a) last()
b) done()
c) finally()
d) complete()
Answer: (c) finally()
Question 209. Which object represents current webpage document?
a) screen
b) window
c) navigator
d) document
Answer: (d) document
Question 210. Which property changes HTML content of element?
a) value
b) innerHTML
c) style
d) className
Answer: (b) innerHTML
Question 211. What is JavaScript mainly used for?
a) Creating databases
b) Creating interactive and dynamic web pages
c) Designing computer hardware
d) Managing operating systems
Answer: (b) Creating interactive and dynamic web pages
Question 212. JavaScript is a type of ______
a) Markup language
b) Styling language
c) Programming language
d) Database language
Answer: (c) Programming language
Question 213. JavaScript is commonly used to make websites more ______.
a) Interactive
b) Expensive
c) Static
d) Offline
Answer: (a) Interactive
Question 214. JavaScript works together with which two technologies to build modern websites?
a) Python and Java
b) HTML and CSS
c) SQL and PHP
d) C and C++
Answer: (b) HTML and CSS
Question 215. JavaScript can run inside ___
a) Web browsers
b) Printers
c) Calculators only
d) BIOS only
Answer: (a) Web browsers
Question 216. JavaScript is an open-source ______ language.
a) Query
b) Scripting
c) Database
d) Markup
Answer: (b) Scripting
Question 217. What can JavaScript change on a webpage?
a) HTML content
b) CSS styles
c) HTML attributes
d) all of the above
Answer: (d) all of the above
Question 218. JavaScript can change ______ on a webpage.
a) HTML content
b) Only images
c) Only text files
d) Only databases
Answer: (a) HTML content
Question 219. Which technology is mainly responsible for the structure of a webpage?
a) CSS
b) Javascript
c) HTML
d) SQL
Answer: (c) HTML
Question 220. Which technology is mainly used to style a webpage?
a) HTML
b) CSS
c) JavaScript
d) SQL
Answer: (b) CSS
Question 221. Which technology is commonly used to add interactivity to webpages?
a) JavaScript
b) HTML
c) CSS
d) SQL
Answer: (a) JavaScript
Question 222. JavaScript can modify HTML ______.
a) Attributes
b) Servers
c) Operating Systems
d) Hard disks
Answer: (a) Attributes
Question 223. JavaScript can ______ HTML elements.
a) Hide and Show
b) Format
c) Manufacture
d) Print only
Answer: (a) Hide and Show
Question 224. JavaScript can be used to validate ____
a) Forms
b) CPUs
c) Printers
d) Hard drives
Answer: (a) Forms
Question 225. Which of the following can JavaScript create?
a) Animations
b) Computer processors
c) Motherboards
d) RAM chips
Answer: (a) Animations
Question 226. JavaScript helps developers create ______ content.
a) Dynamic
b) Printed
c) Mechanical
d) Physical
Answer: (a) Dynamic
Question 227. A webpage that responds to user actions is generally called ______.
a) Interactive
b) Static
c) Printed
d) Offline
Answer: (a) Interactive
Question 228. Which of the following is NOT a common use of JavaScript?
a) Form validation
b) Creating animations
c) Changing CSS styles
d) Manufacturing computer chips
Answer: (d) Manufacturing computer chips
Question 229. JavaScript can change the ______ of an HTML element.
a) CSS style
b) Processor Speed
c) Screen hardware
d) Keyboard layout
Answer: (a) CSS style
Question 230. JavaScript is useful for creating ______ web applications.
a) Interactive
b) Mechanical
c) Printed
d) Hardware-based
Answer: (a) Interactive
Question 231. Which statement about JavaScript is correct?
a) JavaScript can only be used for styling
b) JavaScript can create dynamic web content.
c) JavaScript replaces HTML completely.
d) JavaScript is only a database language.
Answer: (b) JavaScript can create dynamic web content
Question 232. What does JavaScript allow developers to create?
a) Dynamic content
b) Interactive web pages
c) Web applications
d) All of the above
Answer: (d) All of the above
Question 233. Which of the following can JavaScript validate?
a) Forms
b) Computer monitors
c) Motherboards
d) Printers
Answer: (a) Forms
Question 234. JavaScript can make a website more ______.
a) User friendly
b) Mechanical
c) Physical
d) Hardware dependent
Answer: (a) User friendly
Question 235. Which combination is commonly used to build modern websites?
a) HTML + CSS + Javascript
b) SQL + C +Java
c) Python + SQL + C++
d) Excel + Word + Powerpoint
Answer: (a) HTML + CSS +Javascript
Question 236. JavaScript can hide and show ______.
a) HTML elements
b) Computer processors
c) Operating systems
d) Network cables
Answer: (a) HTML elements
Question 237. Which of these is an example of JavaScript functionality?
a) Changing the content of a webpage
b) Manufacturing a keyboard
c) Increasing RAM physically
d) Replacing a CPU
Answer: (a) Changing the content of a webpage
Question 238. JavaScript is commonly executed by a __
a) Web browser
b) Printer
c) Scanner
d) Keyboard
Answer: (a) Web browser
Question 239. Which statement is TRUE about JavaScript?
a) It can change css style
b) It can not interact with HTML
c) It is only used for databases
d) It can not create animations
Answer: (a) It can change css style
Question 240. What is one major purpose of JavaScript in web development?
a) To add behavior and interactivity to webpages
b) To manufacture computers
c) To replace the internet
d) To create physical machines
Answer: (a) To add behavior and interactivity to webpages
Question 241. Who created JavaScript?
a) James Gosling
b) Brendan Eich
c) Denis Ritchie
d) Bjarne stroustrup
Answer: (b) Brendan Eich
Question 242. In which year was JavaScript created?
a) 1990
b) 1993
c) 1995
d) 2000
Answer: (c) 1995
Question 243. JavaScript was originally developed at which company?
a) Microsoft
b) Google
c) Netscape
d) Apple
Answer: (c) Netscape
Question 244. What was JavaScript originally called?
a) Livescript
b) Webscript
c) ECMA Script
d) JScript
Answer: (c) ECMA Script
Question 245. JavaScript was renamed from LiveScript to JavaScript mainly because of a partnership involving which company?
a) Microsoft
b) Sun Microsystems
c) IBM
d) Google
Answer: (b) Sun Microsystems
Question 246. JavaScript was initially created for use in which browser?
a) Internet Explorer
b) Netscape Navigator
c) Google Chrome
d) Firefox
Answer: (b) Netscape Navigator
Question 247. Brendan Eich created JavaScript while working at _____
a) Netscape
b) Microsoft
c) Google
d) IBM
Answer: (a) Netscape
Question 248. JavaScript was designed to add ______ to web pages.
a) Hardware
b) interactivity
c) Storage devices
d) Operating System
Answer: (b) interactivity
Question 249. Which company later developed its own JavaScript implementation called JScript?
a) Microsoft
b) Apple
c) Google
d) IBM
Answer: (a) Microsoft
Question 250. JScript was developed by ______.
a) Microsoft
b) Apple
c) Google
d) IBM
Answer: (a) Microsoft
Question 251. What is ECMAScript?
a) A database
b) A standardized specification for scripting languages
c) A web browser
d) An operating system
Answer: (b) A standardized specification for scripting languages
Question 252. Which organization is responsible for standardizing ECMAScript?
a) W3C
b) ECMA International
c) Microsoft
d) Google
Answer: (b) ECMA International
Question 253. JavaScript became standardized under the name ______.
a) JavaScript
b) JScript
c) ECMAScript
d) LiveScript
Answer: (c) ECMAScript
Question 254. ECMAScript is commonly abbreviated as ______.
a) ES
b) EC
c) JS
d) EM
Answer: (a) ES
Question 255. Which of the following is a standardized version of ECMAScript?
a) ES6
b) HTML6
c) CSS6
d) SQL6
Answer: (a) ES6
Question 256. ES6 was also known as ______.
a) ECMAScript 2015
b) ECMAScript 2005
c) ECMAScript 2020
d) ECMAScript 1995
Answer: (a) ECMAScript 2015
Question 257. Which version introduced many major modern JavaScript features?
a) ES3
b) ES5
c) ES6
d) ES1
Answer: (c) ES6
Question 258. ES6 was released in which year?
a) 2005
b) 2010
c) 2015
d) 2020
Answer: (c) 2015
Question 259. Which of the following is another name for ECMAScript 2015?
a) ES3
b) ES5
c) ES6
d) ES10
Answer: (c) ES6
Question 260. Which browser company was closely associated with the original development of JavaScript?
a) Netscape
b) Google
c) Mozilla
d) Opera
Answer: (a) Netscape
Question 261. Which language is JavaScript NOT the same as, despite having a similar name?
a) Java
b) Python
c) HTML
d) CSS
Answer: (a) Java
Question 262. JavaScript and Java are ______
a) The same language
b) Completely identical technologies
c) Different programming languages
d) Both markup languages
Answer: (c) Different programming languages
Question 263. What was one major reason for creating JavaScript?
a) To make web page interactive
b) To create operating system
c) To design processors
d) To manage databases only
Answer: (a) To make web page interactive
Question 264. Which technology provides the standard specification that JavaScript follows?
a) ECMAScript
b) HTML
c) CSS
d) SQL
Answer: (a) ECMAScript
Question 265. Which of these is a JavaScript engine?
a) V8
b) HTML
c) CSS
d) MySQL
Answer: (a) V8
Question 266. V8 JavaScript engine was developed by ______.
a) Google
b) Microsoft
c) Netscape
d) IBM
Answer: (a) Google
Question 267. Which browser uses the V8 JavaScript engine?
a) Google Chrome
b) Internet Explorer
c) Netscape Navigator
d) Safari only
Answer: (a) Google Chrome
Question 268. JavaScript has evolved over time through different versions of ______.
a) ECMAScript
b) HTML
c) CSS
d) MYSQL
Answer: (a) ECMAScript
Question 269. Which statement about JavaScript history is correct?
a) JavaScript was created in 1995
b) JavaScript was created in 1980.
c) JavaScript was originally called HTMLScript.
d) JavaScript was created by Microsoft.
Answer: (a) JavaScript was created in 1995
Question 270. Which statement best describes the development of JavaScript?
a) It started as a scripting language for webpages and later evolved into a widely used programming language.
b) It was originally created as a database system.
c) It was originally an operating system.
d) It was created only for mobile applications.
Answer: (a) It started as a scripting language for webpages and later evolved into a widely used programming language.
Question 271. Which keyword is used to declare a variable in JavaScript?
a) var
b) variable
c) declare
d) v
Answer: (a) var
Question 272. Which keyword can be used to declare a block-scoped variable?
a) let
b) var
c) define
d) newvar
Answer: (a) let
Question 273. Which keyword is used to declare a constant?
a) constant
b) const
c) fixed
d) static
Answer: (b) const
Question 274. Which of the following is a valid JavaScript variable name?
a) 2name
b) first-name
c) firstName
d) first name
Answer: (c) firstName
Question 275. JavaScript variable names are __
a) Case-sensitive
b) Not Case-sensitive
c) Always uppercase
d) Always lowercase
Answer: (a) Case-sensitive
Question 276. Which symbol is commonly used to end a JavaScript statement?
a) :
b) ;
c) .
d) ,
Answer: (b) ;
Question 277. Which of the following is a valid string?
a) Hello
b) "Hello"
c) Hello"
d) Hello'
Answer: (b) "Hello"
Question 278. Which data type is used to store text?
a) Number
b) Boolean
c) String
d) Object
Answer: (c) String
Question 279. Which data type represents true or false?
a) String
b) Boolean
c) Number
d) undefined
Answer: (b) Boolean
Question 280. What is the data type of 25?
a) String
b) Boolean
c) Number
d) Object
Answer: (c) Number
Question 281. What is the value of the following variable?
a) Number
b) String
c) Boolean
d) Undefined
Answer: (b) String
Question 282. Which operator is used for addition?
a) *
b) /
c) +
d) %
Answer: (c) +
Question 283. What is the result of 10 + 5?
a) 15
b) 105
c) 5
d) 50
Answer: (a) 15
Question 284. What is the result of 10 - 4?
a) 14
b) 6
c) 40
d) 4
Answer: (b) 6
Question 285. What is the result of 5 * 4?
a) 9
b) 1
c) 20
d) 54
Answer: (c) 20
Question 286. What is the result of 20 / 5?
a) 4
b) 5
c) 15
d) 25
Answer: (a) 4
Question 287. Which operator gives the remainder after division?
a) /
b) %
c) //
d) &
Answer: (b) %
Question 288. What is the result of 10 % 3?
a) 3
b) 1
c) 0
d) 10
Answer: (b) 1
Question 289. Which operator is used for assignment?
a) ==
b) ===
c) =
d) =>
Answer: (c) =
Question 290. What does == generally check?
a) Assignment
b) Equality
c) Addition
d) Division
Answer: (b) Equality
Question 291. What does === check?
a) Only value
b) Only data type
c) Value and data type
d) Assignment
Answer: (c) Value and data type
Question 292. What is the result of 5 === 5?
a) true
b) false
c) undefined
d) null
Answer: (a) true
Question 293. What is the result of 5 === 5?
a) true
b) false
c) 5
d) "5"
Answer: (b) false
Question 294. Which operator means "not equal" with type checking?
a) !=
b) !==
c) <>
d) not=
Answer: (b) !==
Question 295. Which function is commonly used to display output in the browser console?
a) print()
b) console.log()
c) display()
d) writeConsole()
Answer: (b) console.log()
Question 296. What will this code display?
a) Hello
b) "Hello" only
c) Nothing
d) Error
Answer: (a) Hello
Question 297. Which function is used to display a popup message in a browser?
a) popup()
b) message()
c) alert()
d) show()
Answer: (c) alert()
Question 298. Which function can be used to take input from a user through a browser dialog?
a) input()
b) prompt()
c) getInput()
d) read()
Answer: (b) prompt()
Question 299. What is the result of the following code?
a) name
b) Rahul
c) "name"
d) Error
Answer: (b) Rahul
Question 300. Which of the following correctly declares a variable named age with the value 20?
a) let age=20;
b) age let =20;
c) variable age=20;
d) let=age 20;
Answer: (a) let age=20;
Question 301. Which of the following is a correct JavaScript comment?
a)
b) //comment
c) ##comment
d) ** comment **
Answer: (b) //comment
Question 302. Which symbol is used for a single-line comment in JavaScript?
a) //
b) ##
c)
d) **
Answer: (a) //
Question 303. Which syntax is used for a multi-line comment?
a) //comment//
b)
c) /**/
d) ##comment##
Answer: (c) /**/
Question 304. What is the output of this code?
a) 1020
b) 30
c) 10+20
d) Error
Answer: (b) 30
Question 305. What is the output?
a) 10
b) 25
c) 35
d) Error
Answer: (b) 25
Question 306. Which keyword allows a variable's value to be changed later?
a) const
b) let
c) fixed
d) constant
Answer: (b) let
Question 307. Which declaration cannot normally be reassigned?
a) let
b) var
c) const
d) variable
Answer: (c) const
Question 308. Which operator has higher precedence?
a) +
b) -
c) *
d) =
Answer: (c) *
Question 309. What is the result of 10 > 5?
a) true
b) false
c) 10
d) 5
Answer: (a) true
Question 310. What is the result of 10 < 5?
a) true
b) false
c) 10
d) error
Answer: (b) false
Question 311. Which operator means "greater than or equal to"?
a) =>
b) >=
c) =<
d) ==>
Answer: (b) >=
Question 312. Which operator means "less than or equal to"?
a) =<
b) <=
c) =<=
d) <==
Answer: (b) <=
Question 313. What is the result of 10 >= 10?
a) true
b) false
c) 10
d) Error
Answer: (a) true
Question 314. What is the result of 5 != 10?
a) true
b) false
c) 5
d) 10
Answer: (a) true
Question 315. Which operator represents logical AND?
a) ||
b) &&
c) !
d) &
Answer: (b) &&
Question 316. Which operator represents logical OR?
a) ||
b) &&
c) !
d) OR
Answer: (a) ||
Question 317. Which operator represents logical NOT?
a) !
b) not
c) ~
d) !=
Answer: (a) !
Question 318. What is the result of true && true?
a) true
b) false
c) undefined
d) null
Answer: (a) true
Question 319. What is the result of true && false?
a) true
b) false
c) undefined
d) null
Answer: (b) false
Question 320. What is the result of true || false?
a) true
b) false
c) error
d) null
Answer: (a) true
Question 321. What is the result of !true?
a) true
b) false
c) undefined
d) null
Answer: (b) false
Question 322. Which value represents the absence of an intentional object value?
a) null
b) empty
c) zero
d) false
Answer: (a) null
Question 323. Which value indicates that a variable has not been assigned a value?
a) null
b) undefined
c) empty
d) NaN
Answer: (b) undefined
Question 324. What is the type of "Hello"?
a) Number
b) Boolean
c) String
d) Object
Answer: (c) String
Question 325. What is the type of true?
a) String
b) Boolean
c) Number
d) Undefined
Answer: (b) Boolean
Question 326. What is the result of "Hello" + " World"?
a) Hello
b) World
c) Hello World
d) Error
Answer: (c) Hello World
Question 327. What does typeof do in JavaScript?
a) Creates a variable
b) Checks the data type of value
c) Converts HTML to CSS
d) Error
Answer: (b) Checks the data type of value
Question 328. What does typeof do in JavaScript?
a) Creates a variable
b) Checks the data type of value
c) Converts HTML to CSS
d) Error
Answer: (b) Checks the data type of value
Question 329. Which keyword is used to declare a variable that can be reassigned?
a) Const
b) let
c) fixed
d) constant
Answer: (b) let
Question 330. Which method is used to display a message in the browser console?
a) print()
b) console.log()
c) display()
d) show()
Answer: (b) console.log()
Question 331. What is the output of the following code?
a) 15
b) 5
c) 50
d) 2
Answer: (b) 5
Question 332. Which operator is used for multiplication in JavaScript?
a) x
b) *
c) #
d) %
Answer: (b) *
Question 333. Which operator is used to increase a variable's value by 1?
a) --
b) +=
c) ++
d) **
Answer: (c) ++
Question 334. Which operator decreases a variable's value by 1?
a) --
b) +=
c) ++
d) //
Answer: (a) --
Question 335. Which operator adds a value to an existing variable and assigns the result back?
a) -=
b) *=
c) +=
d) /=
Answer: (c) +=
Question 336. Which function converts a numeric string into an integer?
a) parseInt()
b) toString()
c) alert()
d) typeof()
Answer: (a) parseInt()
Question 337. What does NaN stand for in JavaScript?
a) No Assigned Number
b) Not a number
c) New and Null
d) Negative and Null
Answer: (b) Not a number
Question 338. Which statement is used to execute code only when a condition is true?
a) if
b) repeat
c) print
d) define
Answer: (a) if
Question 339. Which keyword executes an alternative block when the if condition is false?
a) then
b) otherwise
c) else
d) next
Answer: (c) else
Question 340. Which statement is used to check multiple conditions in sequence?
a) if...else if..else
b) for..in
c) try...catch
d) do...while
Answer: (a) if..else if...else
Question 341. Which operator checks whether two values are strictly equal?
a) =
b) ==
c) ===
d) !=
Answer: (c) ===
Question 342. Which logical operator returns true when both conditions are true?
a) ||
b) |
c) &&
d) =
Answer: (c) &&
Question 343. Which logical operator returns true when at least one condition is true?
a) &&
b) ||
c) !
d) ===
Answer: (b) ||
Question 344. Which operator reverses a Boolean value?
a) &&
b) ||
c) !
d) +
Answer: (c) !
Question 345. Which statement is used to execute one block from several possible options based on an expression's value?
a) if only
b) switch
c) while
d) function
Answer: (b) switch
Question 346. Which keyword stops execution of a switch case and exits the switch statement?
a) if only
b) switch
c) while
d) function
Answer: (b) switch
Question 347. Which keyword is used to define a function in JavaScript?
a) method
b) function
c) define
d) func
Answer: (b) function
Question 348. How do you call a function named greet?
a) call greet;
b) greet[];
c) greet();
d) funcion greet;
Answer: (c) greet();
Question 349. What is a parameter in a function?
a) A value returned by a function
b) A variable listed in a function definition to receive input
c) A javascript comment
d) An HTML element
Answer: (b) A variable listed in a function definition to receive input
Question 350. What is an argument in a function call?
a) A value passed to a function
b) A function name
c) A loop
d) A comment
Answer: (a) A value passed to a function
Question 351. What is an argument in a function call?
a) A value passed to a function
b) A function name
c) A loop
d) A comment
Answer: (a) A value passed to a function
Question 352. Which keyword returns a value from a function?
a) send
b) print
c) return
d) break
Answer: (c) return
Question 353. What happens if a JavaScript function does not explicitly return a value?
a) It returns 0
b) It returns null
c) It returns Undefined
d) It returns false
Answer: (c) It returns Undefined
Question 354. Which loop executes a block of code while a condition is true?
a) If
b) Switch
c) While
d) return
Answer: (c) While
Question 355. Which statement immediately terminates a loop?
a) skip
b) break
c) return
d) next
Answer: (b) break
Question 356. Which loop is guaranteed to execute its body at least once?
a) for
b) while
c) do...while
d) for..in
Answer: (c) do...while
Question 357. Which statement skips the current iteration of a loop and continues with the next iteration?
a) break
b) stop
c) continue
d) exit
Answer: (c) continue
Question 358. Which loop is commonly used when the number of iterations is known in advance?
a) if
b) for
c) switch
d) try
Answer: (b) for
Question 359. Which keyword is used to declare a variable in JavaScript?
a) let
b) print
c) display
d) write
Answer: (a) let
Question 360. Which symbol is used for addition in JavaScript?
a) -
b) +
c) *
d) /
Answer: (b) +
Question 361. Which function displays a popup message in the browser?
a) console.log()
b) prompt()
c) alert()
d) print()
Answer: (c) alert()
Question 362. Which brackets are used to create an array in JavaScript?
a) {}
b) ()
c) []
d) <>
Answer: (c) []
Question 363. What is the output?
a) Apple
b) Mango
c) Banana
d) Error
Answer: (a) Apple
Question 364. What is the index of the first element in a JavaScript array?
a) 1
b) 0
c) -1
d) 2
Answer: (b) 0
Question 365. Which property returns the number of elements in an array?
a) size
b) count
c) length
d) total
Answer: (c) length
Question 366. What is the output?
a) 2
b) 3
c) 4
d) 0
Answer: (b) 3
Question 367. Which method adds an element to the end of an array?
a) push()
b) pop()
c) shift()
d) join()
Answer: (a) push()
Question 368. What is the output?
a) [10,20]
b) [30,10,20]
c) [10,20,30]
d) [10,30]
Answer: (c) [10,20,30]
Question 369. Which method removes the last element from an array?
a) push()
b) pop()
c) shift()
d) slice()
Answer: (b) pop()
Question 370. What is the output?
a) [5,10]
b) [10,15]
c) [5,10,15]
d) [15]
Answer: (a) [5,10]
Question 371. Which method adds an element to the beginning of an array?
a) push()
b) pop()
c) unshift()
d) shift()
Answer: (c) unshift()
Question 372. Which method removes the first element of an array?
a) shift()
b) pop()
c) unshift()
d) push()
Answer: (a) shift()
Question 373. Which property is used to find the length of a string?
a) size
b) length
c) count()
d) total()
Answer: (b) length
Question 374. What is the output?
a) 9
b) 10
c) 11
d) 8
Answer: (b) 10
Question 375. Which method converts a string to uppercase?
a) toUpperCase()
b) toLowerCase()
c) upper()
d) capitialize()
Answer: (a) toUpperCase()
Question 376. What is the output?
a) hello
b) Hello
c) HELLO
d) Error
Answer: (c) HELLO
Question 377. Which method converts a string to lowercase?
a) toSmall()
b) toLowerCase()
c) lower()
d) toUpperCase()
Answer: (b) toLowerCase()
Question 378. What is the output?
a) WELCOME
b) Welcome
c) welcome
d) Error
Answer: (c) welcome
Question 379. Which operator is used to join two strings?
a) -
b) +
c) /
d) %
Answer: (b) +
Question 380. What is the output?
a) Hello
b) World
c) HelloWorld
d) Hello World
Answer: (d) Hello World
Question 381. Which brackets are used to create an object literal in JavaScript?
a) []
b) ()
c) {}
d) <>
Answer: (c) {}
Question 382. Which of the following correctly creates a JavaScript object?
a) let student = ["Rahul"];
b) let student = {name: "Rahul"};
c) let student = (name: "Rahul");
d) let student = ;
Answer: (b) let student = {name: "Rahul"};
Question 383. How can you access the name property of this object?
a) student.name
b) student->name
c) student(name)
d) student/name
Answer: (a) student.name
Question 384. What is the output?
a) Rahul
b) 20
c) name
d) Error
Answer: (b) 20
Question 385. Which keyword is used to create a class in JavaScript?
a) object
b) class
c) functionclass
d) struct
Answer: (b) class
Question 386. Which keyword creates a new object from a class?
a) create
b) class
c) new
d) object
Answer: (c) new
Question 387. Which method runs automatically when a new class instance is created?
a) start()
b) init()
c) constructor()
d) main()
Answer: (c) constructor()
Question 388. Which keyword refers to the current object inside a JavaScript method?
a) self
b) this
c) current
d) object
Answer: (b) this
Question 389. Which method converts a JSON string into a JavaScript value or object?
a) JSON.parse()
b) JSON.stringify()
c) JSON.convert()
d) JSON.object
Answer: (a) JSON.parse()
Question 390. Which method converts a JavaScript object into a JSON string?
a) JSON.parse()
b) JSON.stringify()
c) JSON.convert()
d) JSON.object
Answer: (b) JSON.stringify()
Question 391. What is the output?
a) 10
b) 20
c) 30
d) Error
Answer: (c) 30