For example, I know I can use spread operator to add an element to an array in ES6.
const arr = ["a","b"]
const newArr = [...arr, "c"]
that I get
["a","b","c"]
But how to implement this in an nested array, like
const arr = [["a","b"], ["d"]]
I want to get
newArr1 = [["a","b","c"], ["d"]]
and
newArr2 = [["a","b"],["d","c"]]
Perhaps we can use
[[...arr[0], 'c'], [...arr[1]]]
but what if
const arr = [["a","b"], ["d"],["e"]]
and I still want
[["a","b","c"], ["d"],["e"]]
is there a common way?
[[...arr[0], 'c'], [...arr[1]]]