core_indexOf.call( arr, elem, i )
这是jQuery中的代码,其中core_indexOf等同于Array.prototype.indexOf。
按照我的理解的话,arr.indexOf一路顺着原型链追上去,最后同样是调用了Array.prototype.indexOf,所以是相同的,可是问题在于,call将indexOf中的this置为了arr,可是我觉得在arr.indexOf的this应该是指向Array.prototype的,请问this到底指向哪里呢?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
arr.indexOf的this等于调用该方法的对象,也就是arr。
arr.indexOf的this不是指向Array.prototype,而就是这个arr对象。