您的位置:首页 > Web前端 > JavaScript

JS:访问对象属性的两种方式区别之中括号引用方式

2014-01-07 20:02 627 查看
An advantage of bracket notation is that we are not restricted to just using strings in the brackets. We can also use variables whose values are property names:
var someObj = {propName: someValue};
var myProperty = "propName";
someObj[myProperty]

The last line is exactly the same as using
someObj["propName"]
.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: