the different between call and apply in javascript
function sayColor(spre, ssuf) {alert(spre + this.color + ssuf);};
var obj = new Object();
obj.color = 'red';
sayColor.call(obj, "this is ", " , a very nice"); # this is red a very nice
sayColor( "this is ", " , a very nice"); # this is undefined a very nice
sayColor.apply(obj, new Array("this is ", " a nice very")); #this is red a nice very

浙公网安备 33010602011771号