Answer the question
In order to leave comments, you need to log in
Why doesn't destructuring work?
Faced a problem. I need to swap objects that are stored in an array in vuex.
replacePuzzles({commit, getters},{first,second}){
let puzzles = getters.getPuzzles
console.log(puzzles[first],puzzles[second])
[puzzles[first],puzzles[second]] = [puzzles[second],puzzles[first]]
Answer the question
In order to leave comments, you need to log in
You don't have semicolons, and the language itself doesn't put one between the closing parenthesis and the opening square bracket. Your code is similar to this:
It should be like this:
replacePuzzles({commit, getters},{first,second}){
let puzzles = getters.getPuzzles
console.log(puzzles[first],puzzles[second])
;[puzzles[first],puzzles[second]] = [puzzles[second],puzzles[first]]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question