What is the scope of a variable declared inside a function in JavaScript?
Local scope
Block scope
Global scope
Function scope
What will the browser display after running this JavaScript code: alert('Hello') + ' World!'; ?
alert('Hello') + ' World!';
Hello
Hello World!
World!
An error message
What does the Array.isArray() method return when passed an object?
Array.isArray()
false
undefined
true
"object"
object
What will be the output of the following code?
let i = 0; while (i < 5) { console.log(i); i++; }
1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4
1 2 3 4
What is the purpose of the 'catch' block in a try...catch statement?
To execute code only if an error doesn't occur
To re-throw the caught error
To handle the error thrown in the 'try' block
To specify the type of error to catch
How can you change the text content of an HTML element using JavaScript?
All of the above
element.textContent = 'New text'
element.innerHTML = 'New text'
element.innerText = 'New text'
Which loop in JavaScript is best suited for iterating through the properties of an object?
do-while
while
for
for...in
Which data type represents a sequence of characters in JavaScript?
boolean
string
number
console.log(typeof null);
null
symbol
What is the primary role of the browser's JavaScript engine?
Styling web page elements
Fetching data from a server
Interpreting and executing JavaScript code
Defining the structure of a web page