0

I am currently looking over some code and the developer wrote the following function:

const {functionName} = ...some code...

I haven't seen this type of syntax before. What is this type of function syntax called and what is it used for?

NHerwich
  • 11
  • 6
  • 1
    In case of variables it's called [Object destructuring](http://n-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment). That would be something like: `const { name, age } = person`. But I'm not sure if that's what you mean. – fravolt May 04 '21 at 11:21
  • What @fravolt said is right but if you can share the code we can give a better and detailed answer. – M.Hassan Nasir May 04 '21 at 11:27
  • Yes @fravolt, this is exactly what I've been looking for. Thanks! Edit: The Hyperlink doesn't work for me though. – NHerwich May 04 '21 at 11:29

1 Answers1

0

It is called Destructuring assignment.

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment for details.

htho
  • 947
  • 8
  • 22