В
Size: a a a
t
ᅠ
ᅠ
ᅠ
Function.prototype.myBind = function(context, ...rest1) {
if (context === null || context === undefined) {
return (...rest2) => this(...rest1, ...rest2);
}
let fnContext;
switch (typeof context) {
case 'number':
fnContext = new Number(context);
case 'string':
fnContext = new String(context);
case 'boolean':
fnContext = new Boolean(context);
default:
fnContext = context
}
return (...rest2) => {
const name = window.myBindID ? window.myBindID : 1;
window.myBindID = name + 1;
fnContext[name] = this;
const result = fnContext[name](...rest1, ...rest2);
delete fnContext[name];
return result;
};
};
S
Function.prototype.myBind = function(context, ...rest1) {
if (context === null || context === undefined) {
return (...rest2) => this(...rest1, ...rest2);
}
let fnContext;
switch (typeof context) {
case 'number':
fnContext = new Number(context);
case 'string':
fnContext = new String(context);
case 'boolean':
fnContext = new Boolean(context);
default:
fnContext = context
}
return (...rest2) => {
const name = window.myBindID ? window.myBindID : 1;
window.myBindID = name + 1;
fnContext[name] = this;
const result = fnContext[name](...rest1, ...rest2);
delete fnContext[name];
return result;
};
};
2K
КЗ
2K
КЗ
2K
JH
JH