A
A
Alexander Ivanov2019-04-09 11:31:09
JavaScript
Alexander Ivanov, 2019-04-09 11:31:09

Why doesn't includes and indexOf work when passing a parameter?

methods: {
            togglePlatform () {
                this.findId(7,[1,2])
            },
            findId(val, arr) {
             console.log(arr) //   [1, 2, __ob__: Observer]
             console.log(arr.includes(val)) // [Vue warn]: Error in render: "TypeError: newArr.indexOf is not a function"
            }
       }
// JSON.parse(JSON.stringify(clone)) - эта штука тоже не спасает хоть и уберает обсервер

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2019-04-09
@cimonlebedev

String(arr).indexOf(1)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question