0

Consider the declarations of variable "x" and "y"

const x = 1;
   

const [y] = [1]

What is the meaning of 2nd declaration? Can someone suggest an article about such declaration type.

  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment – ksav Jun 20 '22 at 13:13

1 Answers1

0

This is destructuring assignment.

You are unpacking values from arrays or object properties. In your above code, a const variable y will be defined with value 1.

Tushar Shahi
  • 16,452
  • 1
  • 18
  • 39