既然你如此好学,我就在多说几句吧。以上stupidObject 对象有可以用下面几句话来产生:
var stupidObject = new Object(); // 或者最简单 var stupidObject = {};
stupidObject.name = "yesiam"; // 或者 stupidObject[name] = "yesiam";
stupidObject.nickName = "party time";
stupidObject.age = 21;
stupidObject.gender = "male";
stupidObject.saySomthing = function() {
alert("I'm really stupid");
};
// 前面举例时忘了function后的括号()
想学好JavaScript,还是花点银子去买本书吧。只有一本书值得推荐(其它的都是垃圾):JavaScript: The Definitive Guide
by David Flanagan
Google Book 里有些免费章节:
var stupidObject = new Object(); // 或者最简单 var stupidObject = {};
stupidObject.name = "yesiam"; // 或者 stupidObject[name] = "yesiam";
stupidObject.nickName = "party time";
stupidObject.age = 21;
stupidObject.gender = "male";
stupidObject.saySomthing = function() {
alert("I'm really stupid");
};
// 前面举例时忘了function后的括号()
想学好JavaScript,还是花点银子去买本书吧。只有一本书值得推荐(其它的都是垃圾):JavaScript: The Definitive Guide
by David Flanagan
Google Book 里有些免费章节: