0
const person = {
name: "Mike",
country: "New Zealand"
}
function personUpdate(name, country) {
this.name = name
this.country = country
}
personUpdate.bind(person)
personUpdate('Tony', 'Chile')
为什么不能正常工作? person
仍然具有原始属性“迈克”和“新西兰”。为什么不personUpdate.bind(person)
我想使它,以便personUpdate
this
的每个电话都参照person
对象(并且不使用new
)。对对象的Javacript绑定功能
var boundPersonUpdate = personUpdate.bind(person); boundPersonUpdate('Tony','Chile'); – kangsu