Search posts, tags, users, and pages
In this post, we will create a function to take an array and element as an argument and return the array with the element at the end of the array. Let's break this down into chunks... We need a function. An array and element are required to pass ...
Dave Gillick
@Woolley · London, UK
Markdown supported · ⌘↵ to post
Panda Codes
Is there a reason you'd want to write a function to wrap array.push() in this manner? You've actually made a worse option as array.push will accept multiple arguments, or you can pass it an entire array with the spread operator.
array.push()
array.push
Hi Panda Codes, Many thanks for your feedback. I have updated the post to include why it's best to use the spread operator.
Panda Codes
Is there a reason you'd want to write a function to wrap
array.push()in this manner? You've actually made a worse option asarray.pushwill accept multiple arguments, or you can pass it an entire array with the spread operator.