[Vuejs]-Vue JS – indexOf array is not a function

4👍

This is one of those rare cases in JavaScript where leaving off a semicolon can cause huge problems. These two lines are being evaluated as a single expression:

 let index = this.selectedSeats.indexOf(seat)
 ( index >= 0 ) ? this.selectedSeats.splice(index,1) : this.selectedSeats.push(seat)

It’s trying to execute this.selectedSeats.indexOf(seat)(index>=0)

Add a semicolon at the end of your indexOf(seat); and you should be fine.

Leave a comment