
本文共 3460 字,大约阅读时间需要 11 分钟。
Function.prototype.bind���������JavaScript������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Function.prototype.bind������������������������������������������������������������������������������������������������������������������������
���������������������������������������������axios���������dom���������������������������������������������������������������Function.prototype.bind������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������������������������������������
const a = { i: 2 };function fun(x, y) { alert(x + y); alert(this.i);}
���������������fun(1, 2)���������������������this������������������������������������������muon you {i: undefined}���������������������������������������fun���������������a������������
fun.bind(a)(1, 2)
������������������������������this������������������������a���������������������������������"3"���"2"���
���������������������������������������������������bind���������
function bind() { const ob = this; // ��������������������������� const args = Array.from(arguments); const fn = args[0]; // ������������������������ const boundArgs = args.slice(1); // ��������������������������������������������������������������������� return function(newArgs) { const allArgs = boundArgs.concat(newArgs); return ob.apply(fn, allArgs); };}Function.prototype.bind = bind;
������������������������������������������������������������������������������������������������������������������������������������������������������������bind������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������Web.php������������������������������������ moderne JavaScript������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������bind���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
���������������������������������������bind���������apply���������������������������������������������������������������������������������������������������������bitron function������������newArgs���������������������������������������������������������������
������������������������������������������������������������������bind���������������������pnamic���������������������������������������������������������������
���������������������������������������������Function.prototype.bind������������������������ES6������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
