Method 3: Using the Spread Operator …
If you prefer modern JavaScript features, you can use the spread operator to add an object to an array.
Using the spread operator helps keep your code clean, simple, and easy to understand.
The best part is that you only need a few lines of code. Here’s an example of how you can use it in your code.