Skip to content

Instantly share code, notes, and snippets.

@programmingmentor
programmingmentor / codewars-power-of-bind.js
Created February 28, 2021 19:48
codewars-power-of-bind
// Link to kata
// https://www.codewars.com/kata/5388a9d60b24c52f4c000b5f/
// Solution code:
Function.prototype.bind = function(ctx) {
const func = this;
return function(...args) {
const rightCtx = this === global ? ctx : this;
return func.apply(rightCtx, args);
}