What is the scope of a variable declared with 'var' inside a function?
Global scope
Block scope
Function scope
Lexical scope
Which keyword is used to declare a variable in JavaScript with block-level scope?
block
let
const
var
What is the difference between a function declaration and a function expression in JavaScript?
Function declarations can only be anonymous.
Function declarations are hoisted, while function expressions are not.
Function expressions are hoisted, while function declarations are not.
There is no difference; they are interchangeable.
What is the purpose of the 'do-while' loop in JavaScript?
To skip the current iteration of a loop.
To execute a block of code at least once, and then repeatedly as long as a condition is true.
To declare a function.
To execute a block of code only if a condition is true.
Which property is used to set an attribute's value on an HTML element?
Both of the above
element.setAttribute('attributeName', 'value')
None of the above
element.attributeName = 'value'
How do you define default parameter values in a JavaScript function?
By using the 'defaults' keyword.
Using an if statement inside the function body.
By assigning values to parameters directly within the function definition.
Default parameters are not supported in JavaScript.
What does 'client-side' JavaScript refer to?
JavaScript code executed on a web server
JavaScript code executed on the user's web browser
JavaScript code used for database management
JavaScript code used for server maintenance
Which operator is used to check for strict equality (value and type) in JavaScript?
==
=
===
!=
What is the output of the following JavaScript code: prompt('Enter your name:', 'John Doe');?
prompt('Enter your name:', 'John Doe');
It prints 'Enter your name: John Doe' to the console.
It displays a dialog box with the message 'Enter your name:' and a default input value 'John Doe', returning the user's input as a string.
It creates an alert box with the message 'Enter your name: John Doe'.
It sets the user's name to 'John Doe' in the browser's local storage.
What will the following code snippet log to the console: console.log((function(x) { return x * 2; })(5));
console.log((function(x) { return x * 2; })(5));
5
10
ReferenceError
undefined