What is the primary role of the browser's JavaScript engine?
Interpreting and executing JavaScript code
Fetching data from a server
Styling web page elements
Defining the structure of a web page
Which of these is a valid way to embed JavaScript in an HTML file?
<javascript> alert('Hello!'); </javascript>
<js> alert('Hello!'); </js>
What is the purpose of the typeof operator in JavaScript?
typeof
Checks if a variable is defined
Determines the data type of a variable or expression
Changes the data type of a variable
Converts a variable to a string
Which statement can be used to exit a 'switch' statement?
continue
return
break
exit
What is the scope of a variable declared with 'var' inside a function?
Global scope
Function scope
Lexical scope
Block scope
What is the scope of a variable declared inside a function in JavaScript?
Local scope
Which event is commonly used for handling form submissions?
'click'
'change'
'input'
'submit'
Which loop in JavaScript is best suited for iterating through the properties of an object?
while
for...in
do-while
for
What is the difference between the 'break' and 'continue' statements in a loop?
'break' exits the loop entirely, while 'continue' skips the current iteration and continues with the next.
'break' and 'continue' both exit the loop entirely.
'break' and 'continue' both skip the current iteration.
'break' skips the current iteration, while 'continue' exits the loop entirely.
What is the difference between a function declaration and a function expression in JavaScript?
Function expressions are hoisted, while function declarations are not.
Function declarations are hoisted, while function expressions are not.
There is no difference; they are interchangeable.
Function declarations can only be anonymous.