jskatas.org Continuously Learn JavaScript. Your Way.

Destructuring: assign

Assign variables while destructuring.

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

Assign object property values to new variables while destructuring

for simple objects

  • use a colon after the property name, like so propertyName: newName
  • assign a new name and give it a default value using = <default value>

for function parameter names

  • do it the same way, with a colon behind it
  • giving it a default value is possible too, like above