---
title: "Comment by Panda Codes on \"How to create a function to take an array and append an element at the end.\" | Hashnode"
description: "Is there a reason you&#39;d want to write a function to wrap array.push() in this manner? You&#39;ve actually made a worse option as array.push will accept mult"
url: "https://hashnode.com/posts/how-to-create-a-function-to-take-an-array-and-append-an-element-at-the-end/62ff7bbb8bec3d0c4588bd3c/comment/6302d92d14c73b2c3b913f18"
---

[Discussion](https://hashnode.com/posts/how-to-create-a-function-to-take-an-array-and-append-an-element-at-the-end/62ff7bbb8bec3d0c4588bd3c)

Comment [How to create a function to take an array and append an element at the end.](https://hashnode.com/posts/how-to-create-a-function-to-take-an-array-and-append-an-element-at-the-end/62ff7bbb8bec3d0c4588bd3c)

[Panda Codes](https://hashnode.com/@pandacode)

[Aug 22, 2022](https://hashnode.com/posts/how-to-create-a-function-to-take-an-array-and-append-an-element-at-the-end/62ff7bbb8bec3d0c4588bd3c/comment/6302d92d14c73b2c3b913f18)

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.

[Dave Gillick](https://hashnode.com/@Woolley)

[Aug 22, 2022](https://hashnode.com/posts/how-to-create-a-function-to-take-an-array-and-append-an-element-at-the-end/62ff7bbb8bec3d0c4588bd3c/comment/6302d92d14c73b2c3b913f18#reply-630400b109d19537666eae71)

Hi Panda Codes, Many thanks for your feedback. I have updated the post to include why it's best to use the spread operator.
