Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript default parameters object destructuring

You can use "defaults" in destructuring as well:

(function test({a = "foo", b = "bar"} = {}) {
  console.log(a + " " + b);
})();

This is not restricted to function parameters, 
but works in every destructuring expression.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #default #parameters #object #destructuring
ADD COMMENT
Topic
Name
1+9 =