我以为我的问题会用 this 来回答或 this但我要找的也不是。
我在 Google Script 中有一个对象,想要遍历每个元素:
var dict = {
"foo": "a",
"bar": "b"
};
for each key, element in dict{
print the key and the element
}
这可能吗?
最佳答案
我经常这样做:
var dict = {
"foo": "a",
"bar": "b"
};
function showProperties(){
var keys = [];
for(var k in dict) keys.push(k+':'+dict[k]);
Logger.log("total " + keys.length + "\n" + keys.join('\n'));
}
记录器的结果:
您在脚本编辑器/ View /日志中获取记录器
关于javascript - 迭代 Google Apps 脚本中的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25722682/