Which method is used to select an HTML element with a specific ID?
querySelectorAll()
getElementById()
getElementbyId()
querySelector()
Which operator is used to check for strict equality (value and type) in JavaScript?
===
=
!=
==
What is the purpose of the typeof operator in JavaScript?
typeof
Converts a variable to a string
Determines the data type of a variable or expression
Changes the data type of a variable
Checks if a variable is defined
What is the purpose of the return keyword in a function?
return
It specifies the data type of the function.
It assigns a value to a variable.
It prints a value to the console.
It sends a value back from the function to the caller.
Which of the following is NOT a feature of JavaScript?
Interpreted language
Object-oriented programming capabilities
Client-side scripting language
Strongly typed language
Which method removes the first element from an array and returns it?
shift()
slice()
unshift()
pop()
Which of these is NOT a valid way to create a custom error in JavaScript?
throw new CustomError('This is a custom error')
throw 'This is a custom error'
throw { message: 'This is a custom error' }
throw new Error('This is a custom error')
Which block of code is executed regardless of whether an error is thrown or caught?
catch
finally
try
throw
What value is returned by confirm('Are you sure?') if the user clicks the 'Cancel' button?
confirm('Are you sure?')
undefined
true
false
null
Which of these is a valid way to embed JavaScript in an HTML file?
<js> alert('Hello!'); </js>
<javascript> alert('Hello!'); </javascript>