0

In this sample code:

const Button = props => {
  const { kind, ...other } = props;
  const className = kind === "primary" ? "PrimaryButton" : "SecondaryButton";
  return <button className={className} {...other} />;
};

on the second line, what is the { } referred to in Javascript, so that I can go and look it up and understand how it works. Unfortunately, no example like this exists in the official docs for const:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const

Johann
  • 27,536
  • 39
  • 165
  • 279

1 Answers1

2

That's a Destructuring assignment.

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.

vicpermir
  • 3,544
  • 3
  • 22
  • 34