标签:
var person = new Object(); person.name = "Nicholas"; //"Nicholas" alert(person.name); 但是,我们不能这样写: var name = "Nicholas"; name.age = 27; //undefined alert(name.age);
function addTen(num) { num += 10; return num; } var count = 20; var result = addTen(count); //20,没有变化 alert(count); //30 alert(result);
function setName(obj) { obj.name = "Nicholas"; } var person = new Object(); setName(person); //"Nicholas" alert(person.name);
function setName(obj) { obj.name = "Nicholas"; obj = new Object(); obj.name = "Greg"; } var person = new Object(); setName(person); //"Nicholas" alert(person.name);
标签:
原文地址:http://www.cnblogs.com/dufemeng/p/4355427.html