Last active
August 29, 2015 14:19
-
-
Save domderen/3c901b4652624c159b2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? | |
}; |
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;
}
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
This is how I’d do it: