How to save data from a foreach in HTML in an array of Javascript

I have a query, I'm with a project that uses Laravel, and when I get the control data I use that in the view foreach to restore the data sent, but I also want all the data sent to be stored in an array in Javascript in order to work with them.


@foreach ($ product as $ prod)



At the time of printing the array, only the first data is stored in the list that should display all the data I sent from the controller.
I would appreciate your help.