ninja Chapter4.1
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
JavaScript
function forEach(list,callback) {
for (var n = 0; n < list.length; n++) {
callback.call(list[n], n);
}
}
var weapons=[{type:'butt'},
{type:'fist'},
{type:'knee'}];
forEach(weapons, function(index){
console.log('this=',this,"weapons[index]=",weapons[index],"type=",weapons[index].type)
});