๐Ÿ”ฐdestructuring arguments

๐Ÿšง under construction -> merge

JS โŸฉ operator โŸฉ assignment โŸฉ destructuring โŸฉ arguments

๐Ÿ‘‰ See๏ผš object destructuring for more info.

const {log} = console;

// function parameter by object destructuring
function f ({
  hi = 2,         // default param
  ...options      // other params as an object โญ๏ธ
}={}) {

  log(options);   
  return hi;      
}

// test run
f({x: 1, y: 2, hi: 3});      // 3
// options = { x: 1, y: 2 }

Last updated

Was this helpful?