【题记】expando是什么东西?书上也没有,搜也搜不到,【javascript基础】javascript对象的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;

 

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";

 

完事

 

参考文档:

http://msdn.microsoft.com/zh-cn/library/89t1khd2%28v=VS.94%29.aspx 

http://blogread.cn/it/article.php?id=2419 

 

相关文章:

  • 2021-05-22
  • 2021-07-04
  • 2021-08-18
  • 2021-06-10
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
猜你喜欢
  • 2021-10-29
  • 2021-07-11
  • 2022-12-23
  • 2021-11-02
  • 2021-10-31
  • 2021-10-13
  • 2021-09-03
相关资源
相似解决方案