test: click button and refresh page, code:

window.addEventListener("load", function ()
{
    let arr = [1, 2, 3, 4, 5];
    alert(arr.join());

    document.querySelector("button").addEventListener("click", function ()
    {
        arr.reverse();
    });
});