[英]issue with adding a method in object
I have this object: 我有这个对象:
var Point = {
step: function () {
alert("hello");
}
};
This works: Point.step();
这有效:
Point.step();
. 。
How to make it work with the [ ]
notation? 如何使其使用
[ ]
表示法? Meaning Point["property_name"]
. 含义
Point["property_name"]
。
It is Point["step"]();
这是
Point["step"]();
. 。 Here is the snippet:
这是代码段:
var Point = { step: function () { alert("hello"); } }; Point["step"]();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.