Answer the question
In order to leave comments, you need to log in
How to change the imported array?
There is a file with an array consisting of objects, I want to change it, I import it, but when I try to change it, I get an error that this is an import.
Answer the question
In order to leave comments, you need to log in
Option A.
Work with a copy.
import words from './words';
let badWords = words.slice();
badWords.push("Boo");
// ...
badWords = ['я передумал'];
import words from './words';
const myNewWords = ['иммутабельность', 'констистентность'];
words.splice(0, words.length); // удалили все элементы
words.push(...myNewWords);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question