var people = ['Bill', 'Saul', 'Gaius']; //using each to detect Cylons: Ext.each(people, function (person, index) { var cylon = (index + 1) % 2 == 0; //every second man is a toaster alert(person + (cylon ? ' is ' : ' is not ') + 'a fraking cylon'); }); //is the same as for (var i = 0; i < people.length; i++) { var person = people[i]; var cylon = (index + 1) % 2 == 0; //every second man is a toaster alert(person + (cylon ? ' is ' : ' is not ') + 'a frakin cylon'); };
Ext.each
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.