TypeError:找不到包含在对象中的函数(即使对象是数组) [英] TypeError: Cannot find function includes in object (even though the object is an array)
本文介绍了TypeError:找不到包含在对象中的函数(即使对象是数组)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么应用脚本无法在显然是数组的对象中找到包含的功能.
Why does app scripts not find the function includes in the object that is clearly an Array.
function test() {
var list = ['a', 'b', 'c'];
Logger.log(list.constructor.name) // Array
if ( list.includes('a') ){
Logger.log('yes');
}
return 'done';
}
错误文字:
TypeError: Cannot find function includes in object a,b,c. (line 134, file "Code")
我是google应用程序脚本的新手,我正在生气.我已经在一个在线Javascript控制台中尝试过,一切都很好.
I am new with google app scripts and I am getting mad. I have tried it in a online Javascript console and everything is fine.
推荐答案
由于提供了帮助,因此这是一个替代解决方案.
Due to the comment that helped, this is an alternative solution.
function test() {
var list = ['a', 'b', 'c'];
Logger.log(list.constructor.name) // Array
if ( list.indexOf('a') > -1 ){
Logger.log('Yes'); // 'Yes'
}
return 'done';
}
这篇关于TypeError:找不到包含在对象中的函数(即使对象是数组)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文