call与bind
输出是什么?
const person = { name: 'Lydia' }
function sayHi(age) {
console.log(`${this.name} is ${age}`)
}
sayHi.call(person, 21)
sayHi.bind(person, 21)
A:
undefined is 21
Lydia is 21
B:
function
function
C:
Lydia is 21
Lydia is 21
D:
Lydia is 21
function
最后更新于
这有帮助吗?