1let arr =["a","b","c"];
2// ES6 way
3const copy = [...arr];
4
5// older method
6const copy = Array.from(arr);
1/* Copying arrays or parts of arrays in JavaScript */
2
3var fruit = ["apple", "banana", "fig"]; // Define initial array.
4console.log(fruit); // ["apple", "banana", "fig"]
5
6// Copy an entire array using .slice()
7var fruit2 = fruit.slice();
8console.log(fruit2); // ["apple", "banana", "fig"]
9
10// Copy only two array indicies rather than all three
11// From index 0 (inclusive) to index 2 (noninclusive)
12var fruit3 = fruit.slice(0,2);
13console.log(fruit3); // ["apple", "banana"]
14
1
2{"posts":{"nodes":[{"title":"Making Websites Easier To Talk To","slug":"making-websites-easier-to-talk-to","date":"2020-12-16T13:56:44","content":null,"__typename":"Post"}],"__typename":"RootQueryToPostConnection"}}