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


posted @ 2011-08-23 13:12  酱油哥  阅读(174)  评论(0)    收藏  举报