2010年1月17日星期日

Simply JavaScript : Chapter 2

函数参数列表:

debate("affirmative", "negative");

function debate() 
{ 
var affirmative = arguments[0]; 
var negative = arguments[1]; 
}

新建一个对象:

var Robot = new Object();

Robot.metal = "Titanium"; 
Robot.killAllHumans = function() 
{ 
alert("Exterminate!"); 
}; 
Robot.killAllHumans();

//或者

var Robot = 
{ 
metal: "Titanium", 
killAllHumans: function() 
{ 
alert("Exterminate!"); 
} 
};

没有评论:

发表评论