在我的 JavaScript 中:
console.log($.isArray(thisValue)); //true
strDisplay = thisValue.split(" "); //TypeError: thisValue.split is not a function
“thisValue”是我从 .json 文件获取的对象的属性。在某些情况下,我的对象的属性可能是一个数组。我查看了原始 .json 文件,它似乎已正确格式化为数组。
对这里可能发生的事情有什么想法吗?
谢谢。
最佳答案
.split()
是用于 String
的方法,而不是用于 Array
的方法。
您似乎想要 Array.join
,它将 Array
粘合到 String
中。
关于javascript - jQuery.isArray 是 true,但 split() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13039321/