Sebastian Otarola
Sebastian Otarola

Reputation: 13

TypeError: Undefined is not a function. iOS Safari Evaluating function. CoffeeScript

I'm getting an error on iOS safari when trying to evaluate if there is a match within an array with at regex string.

The Code: 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])

It works without problem on Chrome but iOS safari get's an TypeError with:

TypeError: undefined is not a function (evaluating '_this.splittedString[index].includes(_this.productArray[word])')

which is super strange. And I just can't figure out the error. Thanks.

Upvotes: 0

Views: 2473

Answers (1)

Andrey
Andrey

Reputation: 4050

includes string method is a part of ES6 standard, it is not supported by Safari (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)

Upvotes: 1

Related Questions