Guest User

Untitled

a guest
Jun 18th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. Function.prototype.bindRight = function (context, ...firstArgs) {
  2. return (...secArgs) => {
  3. return this.apply(null, [...secArgs.reverse(), ...firstArgs.reverse()]);
  4. };
  5. };
  6.  
  7. function add(x, y, z) {
  8. return 100 * x + 10 * y + z;
  9. }
  10.  
  11. const add2 = add.bindRight(null, 1, 2);
  12. const result = add2(3);
  13. console.log('--result: ', result); // => 321
Add Comment
Please, Sign In to add comment