+ 1
How to create new array from existing array?
I want to filter specific elements into new array. Eg ['a', 'b', 'c', 'd', 'e', 'f'] to [' c', 'd', 'f']
1 Answer
- 2
use the concat() method.
for example
var array1 = ["ab", "cd", "ef"];
var array2 = ["we", "dd", "ww"];
var array3 = ["fff", "dfv", "jf"];
var arrays = array2.concat(array3);
From my understanding this creates a new array by combining what's in "array2" and "array3" but this doesn't erase array2 & 3. It creates a new array of their combination.