在对象中添加方法时出现问题

issue with adding a method in object

本文关键字:问题 方法 对象 添加      更新时间:2023-09-26

我有这个对象:

var Point = {
    step: function () {
        alert("hello");
    }
};

这是有效的:Point.step();

如何使用[ ]表示法?意思是Point["property_name"]

它是Point["step"]();。以下是片段:

var Point = {
    step: function () {
        alert("hello");
    }
};
Point["step"]();