1. Home
  2. Javascript
  3. Destructuring arguments

It allows you to pass function arguments as an object. You can set default values for the arguments (see "size" argument) and it also allows for omitting arguments when calling a function rather than using null.

#javascript#object#es6
function buildElement({ color, shape, size = 20, callback }){
    // Do something...
}

var el1 = buildElement({ color, shape, size: 10, callback: function(){} });
var el2 = buildElement({ color, size });
copy
Full Javascript cheatsheet