Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

polyfill for call

Function.prototype.myCall = function (...args) {
  let obj = args[0]
  const params = args.slice(1)

  obj = {
    ...obj,
    fn: this
  }

  return obj.fn(...params)
}
 
PREVIOUS NEXT
Tagged: #polyfill #call
ADD COMMENT
Topic
Name
4+7 =