Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

polyfill of bind

Function.prototype.cbind = function (...outer_args) {
    let that = this,
        params = outer_args.slice(1),
        obj = outer_args[0];

    return function (...inner_args) {
        that.apply(obj, [...params, ...inner_args]);
    }
}
 
PREVIOUS NEXT
Tagged: #polyfill #bind
ADD COMMENT
Topic
Name
8+1 =