在谷歌脚本中,在我拆分字符串后,我无法获得结果数组的长度。我想这不是一个数组?如果是这样,如何将其转换为具有长度值的数组?
function splitAndCount() {
str = "33,34,35"; //example string
var stringSplit = str.split(","); //split string
return stringSplit.length(); //
// TypeError: Cannot call property length in object 33,34,35. It is not a function, it is "number".
}
这不是函数,而是属性
function splitAndCount() {
str = "33,34,35"; //example string
var stringSplit = str.split(","); //split string
return stringSplit.length
}
console.log(splitAndCount())
从stringSplit.length中删除括号,它不是函数
function splitAndCount() {
str = "33,34,35"; //example string
var stringSplit = str.split(","); //split string
return **stringSplit.length**;
}