1

I've already used the new syntax for a while, and now I'd like to know more about it:

function func({ foo, bar }) {
    console.log(foo, bar);
}

func({ foo: "my-foo", bar: "my-bar" });

The part of syntax that I'm asking about is the way of declaring the arguments in curly braces.

Parzh from Ukraine
  • 7,999
  • 3
  • 34
  • 65
  • These are object literals. You can read more about these on [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Object_literals). – mnme Apr 28 '17 at 20:54

1 Answers1

1

It is just Property shorthand syntax, which is part of ES6 implementation.

function func({ foo, bar }) {

is nothing but

function func({ foo: foo, bar: bar }) {

http://es6-features.org/#ParameterContextMatching

Sushanth --
  • 55,259
  • 9
  • 66
  • 105