私は Javascript の call() メソッドについて学んでおり、この例を理解しようとしています。今私の質問は次のとおりです。
- コンソール (ブラウザ) に何も表示されないのはなぜですか。console.log() メソッド; 動かない?
- この匿名機能はどのように機能していますか?
ありがとうございました!
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); } }).call(animals[i], i); // I cant understand this anonymus func ? :( }