大佬教程收集整理的这篇文章主要介绍了为什么 Function.prototype.call() 在 console.log() 之前执行?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
为什么 Function.prototype.call() 在 console.log() 之前执行?
function Product(name,pricE) {
this.name = name;
this.price = price;
}
function Food() {
console.log(this)
Product.call(this,'cheese',5);
this.category = 'food';
}
new Food()
它不会在 GET /a
之前执行,正如其他人提到的,它是由对该对象的实时引用引起的,因此您将始终看到该对象的最新值。
检查示例
console.log
更新
如果你没有打开对象,你可以看到当前值(第一个是一个空对象 function Product(name,pricE) {
this.name = name;
this.price = price;
}
function Food() {
console.log(this)
Product.call(this,'cheese',5);
console.log(this)
this.category = 'food';
}
new Food()
,第二个有值),我用箭头指向它。如果您打开该对象,您将看到实时引用,这对于两个日志都是相同的。
以上是大佬教程为你收集整理的为什么 Function.prototype.call() 在 console.log() 之前执行?全部内容,希望文章能够帮你解决为什么 Function.prototype.call() 在 console.log() 之前执行?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。