您的位置:首页 > 移动开发

the different between call and apply in javascript

2011-08-23 13:12 561 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: