gpt4 book ai didi

javascript - TypeError: Undefined 不是一个函数。 iOS Safari 评估功能。 CoffeeScript

转载 作者:行者123 更新时间:2023-11-29 01:41:36 25 4
gpt4 key购买 nike

我在 iOS Safari 上尝试评估正则表达式字符串数组中是否存在匹配项时出现错误。

代码:this.productArray = ['array', 'with', 'stuff']

this.splittedString = string.split('/(\n\r|\r\n)|( )/igm')

    _.each this.splittedString, (word, index) =>
for word of this.productArray
if this.splittedString[index].includes(this.productArray[word])
this.pushToArray('matchedProducts', this.productArray[word])

它在 Chrome 上运行没有问题,但 iOS safari 会出现 TypeError:

类型错误:未定义不是函数(正在计算“_this.splittedString[index].includes(_this.productArray[word])”)

这太奇怪了。而且我只是无法弄清楚错误。谢谢。

最佳答案

includes 字符串方法是 ES6 标准的一部分,Safari 不支持它 ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes )

关于javascript - TypeError: Undefined 不是一个函数。 iOS Safari 评估功能。 CoffeeScript ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32327801/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com