JavaScript Fundamentals

JavaScript Fundamentals Quiz

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What is the correct syntax for declaring a variable in JavaScript?

  1. var variableName;
  2. let variableName;
  3. const variableName;
  4. All of the above
Question 2 Multiple Choice (Single Answer)

What is the difference between var, let, and const in JavaScript?

  1. var is used for global variables, let is used for local variables, and const is used for constants.
  2. var is used for variables that can be reassigned, let is used for variables that cannot be reassigned, and const is used for constants.
  3. var is used for variables that are declared at the top of a function, let is used for variables that are declared within a block, and const is used for constants.
  4. None of the above
Question 3 Multiple Choice (Single Answer)

What is the correct syntax for creating a function in JavaScript?

  1. function functionName() { ... }
  2. const functionName = () => { ... }
  3. let functionName = () => { ... }
  4. All of the above
Question 4 Multiple Choice (Single Answer)

What is the difference between a function declaration and a function expression in JavaScript?

  1. A function declaration is hoisted to the top of the scope, while a function expression is not.
  2. A function declaration can be called before it is defined, while a function expression cannot.
  3. A function declaration can be used as a value, while a function expression cannot.
  4. None of the above
Question 5 Multiple Choice (Single Answer)

What is the correct syntax for creating an array in JavaScript?

  1. const arrayName = [];
  2. let arrayName = [];
  3. var arrayName = [];
  4. All of the above
Question 6 Multiple Choice (Single Answer)

What is the difference between an array and an object in JavaScript?

  1. An array is an ordered collection of values, while an object is an unordered collection of key-value pairs.
  2. An array can only store primitive values, while an object can store any type of value.
  3. An array can be accessed using an index, while an object can be accessed using a key.
  4. All of the above
Question 7 Multiple Choice (Single Answer)

What is the correct syntax for creating an object in JavaScript?

  1. const objectName = {};
  2. let objectName = {};
  3. var objectName = {};
  4. All of the above
Question 8 Multiple Choice (Single Answer)

What is the difference between a property and a method in JavaScript?

  1. A property is a key-value pair, while a method is a function.
  2. A property can be accessed using a dot (.) operator, while a method can be called using parentheses.
  3. A property can be changed, while a method cannot.
  4. None of the above
Question 9 Multiple Choice (Single Answer)

What is the correct syntax for accessing a property of an object in JavaScript?

  1. objectName.propertyName
  2. objectName['propertyName']
  3. Both of the above
  4. None of the above
Question 10 Multiple Choice (Single Answer)

What is the correct syntax for calling a method of an object in JavaScript?

  1. objectName.methodName()
  2. objectName'methodName'
  3. Both of the above
  4. None of the above
Question 11 Multiple Choice (Single Answer)

What is the correct syntax for creating a loop in JavaScript?

  1. for (let i = 0; i < array.length; i++) { ... }
  2. for (const i in array) { ... }
  3. for (const i of array) { ... }
  4. All of the above
Question 12 Multiple Choice (Single Answer)

What is the difference between a break statement and a continue statement in JavaScript?

  1. A break statement exits the loop immediately, while a continue statement skips the current iteration of the loop and continues with the next iteration.
  2. A break statement exits the loop immediately, while a continue statement exits the current iteration of the loop and starts the next iteration.
  3. A break statement skips the current iteration of the loop and continues with the next iteration, while a continue statement exits the loop immediately.
  4. None of the above
Question 13 Multiple Choice (Single Answer)

What is the correct syntax for creating a conditional statement in JavaScript?

  1. if (condition) { ... }
  2. if (condition) { ... } else { ... }
  3. if (condition) { ... } else if (condition) { ... } else { ... }
  4. All of the above
Question 14 Multiple Choice (Single Answer)

What is the correct syntax for creating a switch statement in JavaScript?

  1. switch (expression) { case value1: ...; break; case value2: ...; break; ...; default: ...; }
  2. switch (expression) { case value1: ...; case value2: ...; ...; default: ...; }
  3. switch (expression) { case value1: ...; break; case value2: ...; ...; }
  4. None of the above
Question 15 Multiple Choice (Single Answer)

What is the correct syntax for creating a function in JavaScript?

  1. function functionName() { ... }
  2. const functionName = () => { ... }
  3. let functionName = () => { ... }
  4. All of the above