Hmmm, now you are mutating fruit array. Are you sure you were not trying to do something like
const fruitsAndVegetables = fruits.concat(vegetables); const fruitsAndVegetables = fruits.slice(); fruitsAndVegetables.unshift('carrot');
I don't believe there is a neat little 1 liner to do the equivalent without wrapping 'carrot' in a temp array.
I feel the same way...the new syntax is much more compact.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hmmm, now you are mutating fruit array.
Are you sure you were not trying to do something like
I don't believe there is a neat little 1 liner to do the equivalent without wrapping 'carrot' in a temp array.
I feel the same way...the new syntax is much more compact.