Apply shares defined variable in functions. Second arguments is first arguments in object functions.
function Person( name,ateru) { this.name = name; this.ateru = ateru; } function sayHello( s ) { alert( s + this.name+ '!'+this.ateru); } var p = new Person("なんじゃこりゃー!","あてません"); sayHello.apply(p,["電気関係"]);
forEach has one argument. This arguments is callback which has three arguments. It has value,index and target object.
function printElt(element, index) { alert('[' + index + '] is ' + element); } var a = new Array('a','b','c'); a.forEach(printElt);