Контекст функции привязки

const bind = (fn, context, …boundArgs) => (…args) =>
  fn.apply(context, […boundArgs, …args]);
function greet(greeting, punctuation) {
  return greeting + ' ' + this.user + punctuation;
}
const freddy = { user: 'fred' };
const freddyBound = bind(greet, freddy);
console.log(freddyBound('hi', '!')); // 'hi fred!'
Функции JavaScript