【题记】expando是什么东西?书上也没有,搜也搜不到,,怒了,咋整,还是使劲搜吧
【正文】expando 是 expandable object 的缩写,表示可扩展的对象。expando property 表示可扩展对象的动态属性,运行时添加的。expando 可以直接表示 expando property.
如果属性的名称是简单的标识符,则可在对象名称与句点之后加入该属性,如:
1 var myObj = new Object();
2
3 // Add two expando properties, 'name' and 'age'
4 myObj.name = "Fred";
5 myObj.age = 42;
2
3 // Add two expando properties, 'name' and 'age'
4 myObj.name = "Fred";
5 myObj.age = 42;
JavaScript 中所有 expando 属性的名称先转换为字符串,然后再添加到对象后。
var myObj = new Object();
// Add two expando properties that cannot be written in the
// object.property syntax.
// The first contains invalid characters (spaces), so must be
// written inside square brackets.
myObj["not a valid identifier"] = "This is the property value";
// The second expando name is a number, so it also must
// be placed inside square brackets
myObj[100] = "100";
// Add two expando properties that cannot be written in the
// object.property syntax.
// The first contains invalid characters (spaces), so must be
// written inside square brackets.
myObj["not a valid identifier"] = "This is the property value";
// The second expando name is a number, so it also must
// be placed inside square brackets
myObj[100] = "100";
完事
参考文档:
http://msdn.microsoft.com/zh-cn/library/89t1khd2%28v=VS.94%29.aspx
http://blogread.cn/it/article.php?id=2419