jskatas.org Continuously Learn JavaScript. Your Way.

Destructuring: defaults

When destructuring you can also use default values.

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.

When destructuring you can also provide default values

  • just assign a default value, like so a=1
  • for a missing value
  • in an object
  • if the value is undefined
  • also a string works with defaults