What is the scope of a variable declared inside a function in JavaScript?
Global scope
Local scope
Block scope
Function scope
What is the purpose of the 'do-while' loop in JavaScript?
To execute a block of code only if a condition is true.
To declare a function.
To execute a block of code at least once, and then repeatedly as long as a condition is true.
To skip the current iteration of a loop.
What will be the output of the following code?
console.log(typeof null);
symbol
object
undefined
null
Which statement can be used to exit a 'switch' statement?
break
continue
return
exit
How can you loop through the properties of an object myObject?
myObject
while (myObject.hasNext()) {...}
for (let i = 0; i < myObject.length; i++) {...}
for (let key in myObject) {...}
myObject.forEach(property => {...})
How can you change the text content of an HTML element using JavaScript?
All of the above
element.textContent = 'New text'
element.innerText = 'New text'
element.innerHTML = 'New text'
What is the correct way to add an event listener that logs 'Button Clicked!' to the console when a button with the ID 'myButton' is clicked?
document.getElementById('myButton').addEventListener('click', console.log('Button Clicked!'));
document.getElementById('myButton').addEventListener('click', function() { console.log('Button Clicked!'); });
document.querySelector('#myButton').addEventListener('click', () => console.log('Button Clicked!'));
document.querySelector('#myButton').onclick = console.log('Button Clicked!');
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
Checks if a variable is defined
Changes the data type of a variable
Determines the data type of a variable or expression
Converts a variable to a string
Is it possible to have multiple 'catch' blocks associated with a single 'try' block?
Yes, to handle different error types specifically
No, you can only have one 'catch' per 'try'
Only if you re-throw the error inside the first 'catch'
Only if the 'try' block is nested inside another 'try'