Google Apps脚本中的数组支持哪些功能? [英] What functions do Arrays in Google Apps Script support?
问题描述
我不断发现GAS中缺少数组函数,例如,调用find
会给出错误:Cannot find function find in object
I keep on finding that Array functions are missing in GAS, eg calling find
gives the error: Cannot find function find in object
我能找到的唯一文档有些模棱两可: https://developers.google.com/apps-script/guides/services/#basic_javascript_features
The only docs I can find on this are somewhat ambiguous: https://developers.google.com/apps-script/guides/services/#basic_javascript_features
Apps Script基于JavaScript 1.6,以及1.7和1.8中的一些功能.因此,除了内置和高级的Google服务之外,还提供了许多基本的JavaScript功能:您可以使用Array,Date,RegExp等常见对象,以及Math和Object全局对象.但是,由于Apps脚本代码在Google的服务器上运行(除了HTML服务页面以外,不在客户端),因此无法使用基于浏览器的功能,例如DOM操作或Window API.
Apps Script is based on JavaScript 1.6, plus a few features from 1.7 and 1.8. Many basic JavaScript features are thus available in addition to the built-in and advanced Google services: you can use common objects like Array, Date, RegExp, and so forth, as well as the Math and Object global objects. However, because Apps Script code runs on Google's servers (not client-side, except for HTML-service pages), browser-based features like DOM manipulation or the Window API are not available.
如何查看Array上可用的确切方法?
How can I see what exact methods are available on Array?
推荐答案
Logger.log(Object.getOwnPropertyNames(Array.prototype))
给出以下内容,我认为这是正确的列表:
Logger.log(Object.getOwnPropertyNames(Array.prototype))
gives the following, which I think it is the correct list:
[constructor, toString, toLocaleString, toSource, join, reverse, sort, push, pop, shift, unshift, splice, concat, slice, indexOf, lastIndexOf, every, filter, forEach, map, some, reduce, reduceRight, length]
这篇关于Google Apps脚本中的数组支持哪些功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!