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