call的使用demo
另一个版本
by Mike Lin
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
JavaScript
let animal = function(location, age){
console.log(`I am a ${this.type}, my name is ${this.name}, my home is ${location}, age is ${age}`);
}
let dog = {
type: 'dog',
name: 'wangwang'
}
animal();
animal.call(dog, 'hangzhou', 10);