Skip to content

Instantly share code, notes, and snippets.

@domderen
Last active August 29, 2015 14:19
Show Gist options
  • Save domderen/3c901b4652624c159b2d to your computer and use it in GitHub Desktop.
Save domderen/3c901b4652624c159b2d to your computer and use it in GitHub Desktop.
const fun = ({param1 = 'some default value', param2 = 'other default value'} = {}) => {
console.log(param1);
console.log(param2);
console.log(options); // Can I somehow get access to the object that has param1 and param2 inside?
console.log(arguments[0]); // Is this the only way?
};
@naholyr
Copy link

naholyr commented Apr 16, 2015

Done here this way: https://github.com/lmtm/node-pushpull/blob/master/src/pull.js

// access to options + simpler to read
(options = {}) => {
  // wanna know details ans defaults?
  // + access to individual params
  let {
    param1 = "...",
    param2 = "..."
  } = options;
}

@rauschma
Copy link

Right, @naholyr’s code is the actual solution, I showed how to use a rest parameter instead of arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment