Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

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

View

What does the following code return?

View

Which of the following is true about destructuring?

View

What does the following code return?

View

How do you assign default values during destructuring if a property is missing from the object?

View

What is the result of the following code?

View

Can you rename properties while destructuring?

View

What does the following code return?

View

How do you destructure a nested object?

View

What does the following code return?

View

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

const { a, b } = obj;
const [a, b] = obj;
const a = obj.a, b = obj.b;
const obj = {a, b};

What does the following code return?

const person = { name: "John", age: 30 }; const { name, age } = person; console.log(name, age);

undefined undefined
"John" 30
["John", 30]
null null

Which of the following is true about destructuring?

You can skip properties that you don’t need
You must assign all properties when destructuring
Destructuring cannot be used on nested objects
Destructuring only works with arrays

What does the following code return?

const person = { name: "John", age: 30, city: "New York" }; const { name, city } = person; console.log(city);

John
undefined
New York
null

How do you assign default values during destructuring if a property is missing from the object?

{ propertyName = defaultValue }
{ propertyName ? defaultValue }
{ propertyName || defaultValue }
{ propertyName = defaultValue || undefined }

What is the result of the following code?

const person = { name: "Jane" }; const { name, age = 25 } = person; console.log(age);

undefined
25
null
NaN

Can you rename properties while destructuring?

Yes, using the : syntax
Yes, by assigning to new variables
No, property names must stay the same
Only with arrays

What does the following code return?

const { length: len } = "hello"; console.log(len);

undefined
5
hello
null

How do you destructure a nested object?

{ nestedObj: { propName } }
{ propName.nestedObj }
{ propName { nestedObj } }
const nestedObj = obj;

What does the following code return?

const person = { name: "John", address: { city: "New York", zip: 10001 } }; const { address: { city } } = person; console.log(city);

New York
John
undefined
10001