Created
September 11, 2018 22:18
-
-
Save howarddierking/0919f9a5384ccb288728386cfc0ab30c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// This succesfully merges the supplied object with the state object | |
function builder(){ | |
let state = {}; | |
return { | |
options: function (){ | |
state = mergeFragment('opts', state, optionsFragment(...arguments)); | |
}, | |
product: function(){ | |
return state; | |
} | |
} | |
} | |
// Instead of correctly updating state, this sets its value to `Function f1` | |
function builder(){ | |
let state = {}; | |
return { | |
options: () => { | |
state = mergeFragment('opts', state, optionsFragment(...arguments)); | |
}, | |
product: () => { | |
return state; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you considered that
Arrow functions do not have their own arguments object.
so in the second case,arguments
will reference the arguments of the enclosing scope (not sure what you mean by function f1), I would expect it references arguments of the builder function.