Questions
What is the correct syntax for declaring a variable in JavaScript?
- var variableName;
- let variableName;
- const variableName;
- All of the above
What is the difference between var, let, and const in JavaScript?
-
varis used for global variables,letis used for local variables, andconstis used for constants. -
varis used for variables that can be reassigned,letis used for variables that cannot be reassigned, andconstis used for constants. -
varis used for variables that are declared at the top of a function,letis used for variables that are declared within a block, andconstis used for constants. - None of the above
What is the correct syntax for creating a function in JavaScript?
- function functionName() { ... }
- const functionName = () => { ... }
- let functionName = () => { ... }
- All of the above
What is the difference between a function declaration and a function expression in JavaScript?
- A function declaration is hoisted to the top of the scope, while a function expression is not.
- A function declaration can be called before it is defined, while a function expression cannot.
- A function declaration can be used as a value, while a function expression cannot.
- None of the above
What is the correct syntax for creating an array in JavaScript?
- const arrayName = [];
- let arrayName = [];
- var arrayName = [];
- All of the above
What is the difference between an array and an object in JavaScript?
- An array is an ordered collection of values, while an object is an unordered collection of key-value pairs.
- An array can only store primitive values, while an object can store any type of value.
- An array can be accessed using an index, while an object can be accessed using a key.
- All of the above
What is the correct syntax for creating an object in JavaScript?
- const objectName = {};
- let objectName = {};
- var objectName = {};
- All of the above
What is the difference between a property and a method in JavaScript?
- A property is a key-value pair, while a method is a function.
- A property can be accessed using a dot (.) operator, while a method can be called using parentheses.
- A property can be changed, while a method cannot.
- None of the above
What is the correct syntax for accessing a property of an object in JavaScript?
- objectName.propertyName
- objectName['propertyName']
- Both of the above
- None of the above
What is the correct syntax for calling a method of an object in JavaScript?
- objectName.methodName()
- objectName'methodName'
- Both of the above
- None of the above
What is the correct syntax for creating a loop in JavaScript?
- for (let i = 0; i < array.length; i++) { ... }
- for (const i in array) { ... }
- for (const i of array) { ... }
- All of the above
What is the difference between a break statement and a continue statement in JavaScript?
- A
breakstatement exits the loop immediately, while acontinuestatement skips the current iteration of the loop and continues with the next iteration. - A
breakstatement exits the loop immediately, while acontinuestatement exits the current iteration of the loop and starts the next iteration. - A
breakstatement skips the current iteration of the loop and continues with the next iteration, while acontinuestatement exits the loop immediately. - None of the above
What is the correct syntax for creating a conditional statement in JavaScript?
- if (condition) { ... }
- if (condition) { ... } else { ... }
- if (condition) { ... } else if (condition) { ... } else { ... }
- All of the above
What is the correct syntax for creating a switch statement in JavaScript?
- switch (expression) { case value1: ...; break; case value2: ...; break; ...; default: ...; }
- switch (expression) { case value1: ...; case value2: ...; ...; default: ...; }
- switch (expression) { case value1: ...; break; case value2: ...; ...; }
- None of the above
What is the correct syntax for creating a function in JavaScript?
- function functionName() { ... }
- const functionName = () => { ... }
- let functionName = () => { ... }
- All of the above