Last active
June 17, 2024 20:54
-
-
Save woshichuanqilz/a65a83b7494515415a1c8c2236551775 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function greet(message) { | |
console.log(`${message}, ${this.name}!`); | |
} | |
const person = { | |
name: 'John' | |
}; | |
// 使用apply调用函数,并将person对象作为上下文,参数值作为数组传递 | |
greet.apply(person, ['Hello']); // 输出:Hello, John! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment