1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <script src="https://google.github.io/traceur-compiler/bin/traceur.js"></script>
<script src="https://google.github.io/traceur-compiler/src/bootstrap.js"></script>
<script type="module">
let
curryN = ( n ) => {
return (
F,
s = [],
R = ( ...args ) => {
console.log( F, s, args );
return ( s.push( ...args ), --n ? R : F.call( ...s ) );
}
) => {
return R;
}
};
console.log(
curryN( 3 )( "".substring )( "hello world!" )( 6 )( 11 ) === "world"
);
/*
substring() { [native code] } [] ["hello world!"]
substring() { [native code] } ["hello world!"] [6]
substring() { [native code] } ["hello world!", 6] [11]
true
*/
</script> |