【发布时间】:2017-12-01 03:13:34
【问题描述】:
我正在尝试在 google 脚本中的对象上使用 findIndex(),但它不起作用。这是一个例子:
function myFunction() {
var searchingJohn = "John";
var DATA = {namesList: []};
DATA.namesList.push({name: "John", otherDataForThisName: []});
var result = DATA.namesList.findIndex(function (element)
{return element.name == this;}, searchingJohn);
return result;
}
这在 javascript 控制台中运行良好,但 google 脚本返回“TypeError:Fonction findIndex not found in object.....”
【问题讨论】:
-
什么是谷歌脚本?
-
你用的是什么浏览器?
findIndex是 ES6 方法,在 IE 中不可用。 -
另外,
this在回调函数中也不起作用。
标签: javascript google-apps-script indexof