<script>
var animals = [
{species: 'Lion', name: 'King'},
{species: 'Whale', name: 'Fail'}
];
for (var i = 0; i < animals.length; i++) {
(function (i) {
this.print = function () {
console.log('#' + i + ' ' + this.species + ': ' + this.name);
}
this.print();
}).call(animals[i], i);
}
</script>
问题:
1.为什么要这样写:this.print、this.species、this.name?我试图删除“这个”,并在控制台日志中显示“未定义”
2.call(animals[i], i)
和有什么区别call(this, i)
?