bind.js 444 B

1234567891011121314
  1. 'use strict';
  2. /**
  3. * Create a bound version of a function with a specified `this` context
  4. *
  5. * @param {Function} fn - The function to bind
  6. * @param {*} thisArg - The value to be passed as the `this` parameter
  7. * @returns {Function} A new function that will call the original function with the specified `this` context
  8. */
  9. export default function bind(fn, thisArg) {
  10. return function wrap() {
  11. return fn.apply(thisArg, arguments);
  12. };
  13. }