vanishcode / Blog

vanishcodeのblog
https://vanishcode.com
6 stars 0 forks source link

笔记【JavaScript深入之bind的模拟实现】 #46

Open vanishcode opened 6 years ago

vanishcode commented 6 years ago

https://github.com/mqyqingfeng/Blog/issues/12

我自己犯得糊涂~

for(let i = 1, len = arguments.length; i < len; i++) {
        args.push('arguments[' + i + ']');
}

let result = eval('obj.fn(' + args +')');

之前疑惑,为啥不这样

args.push(arguments[i]);
return obj.fn(args);

其实真是犯了糊涂,这样会导致数组全部合并为一个字符串而不是多个