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

AndroidDev
  • 20,063
  • 26
  • 131
  • 216

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
  • 2,653
  • 3
  • 18
  • 27