MCQ Bank
What does the == operator check in JavaScript?
- A) Both value and data type
- B) Reference equality
- C) Only the data type
- D) Only the value
What is meant by DOM traversing in jQuery?
- A) Select on element and move upwards or downwards to reach the required elements
- B) Select child, parent, ancestor, current, descendant and sibling
- C) Find the desired elements on the basis of their relationship with other elements
- D) All of the given options
What does the === operator check in JavaScript?
- A) Both value and data type
- B) Reference equality
- C) Only the data type
- D) Only the value
In JavaScript, the Window object represents:
- A) The browser’s main window or tab environment
- B) The file system
- C) A database connection
- D) The server environment
AJAX allows:
- A) Page reload always
- B) No server communication
- C) Only HTML rendering
- D) Partial page updates
When should you use objects instead of arrays in JavaScript?
- A) When you want to avoid using new Array()
- B) When you want the element names to be numbers
- C) When you want the element names to be strings (text)
- D) When you want to create a hash array
The setInterval() function is used to:
- A) Execute code repeatedly at fixed time intervals
- B) Stop all timers
- C) Execute code once after delay
- D) Execute code only on errors
Which object is the keystone of AJAX?
- A) DOM
- B) JSON
- C) XMLHttpRequest
- D) Fetch API only
What is the purpose of the throw statement in JavaScript?
- A) It creates a custom error message
- B) It ignores the error
- C) It stops a loop
- D) It declares a variable
Why should we avoid reserved words for variables?
- A) Reduce memory
- B) Improve speed
- C) Avoid syntax errors
- D) Increase loops
What is the result of Number(true)?
- A) true
- B) 1
- C) false
- D) 0
What is the result of typeof "Hello"?
- A) string
- B) number
- C) boolean
- D) object
What does else do?
- A) Executes when condition is true
- B) Loops code
- C) Executes when condition is false
- D) Ends program
What does validateForm() function return on invalid input?
- A) undefined
- B) null
- C) false
- D) true
What does the i modifier (flag) do in a regular expression?
- A) Matches exact text only
- B) Searches multiple lines
- C) Ignores case (case-insensitive search)
- D) Searches the whole text globally
What is the purpose of compare function in sort()?
- A) To define custom sorting order
- B) To reverse array
- C) To delete elements
- D) To join arrays
What is the role of the default case in a switch statement?
- A) It executes when no matching case is found
- B) It executes first in all cases
- C) It is a mandatory case
- D) It must always be written at the end
How can we access a form using JavaScript?
- A) document.forms["formName"]
- B) window.form()
- C) document.getElementByClass()
- D) getForm()
What is the result of typeof null?
- A) object
- B) undefined
- C) string
- D) null
What is a breakpoint in debugging?
- A) A loop inside a program
- B) A variable used in JavaScript
- C) A point where code execution temporarily stops for checking values
- D) A type of error in code