Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 AS3 中是否可以遍历具有给定属性字符串的对象?
有没有办法将data["xyz"]转换为data[x][y][z]?
谢谢
那这个呢?
var keys = "x.y.z".split("."); var access_property = function(object, keys) { for each (var key in keys) { object = object[key]; } return object; } var prop = access_prop(data, "x.y.z");
我没有对此进行测试,并且没有错误处理,例如,如果没有给定名称的键。