Why parentheses here

I’ve been learning about the spread operator. I cannot find anywhere why this function is in parentheses.
Can some one explain this to me?

const arr1 = ["JAN", "FEB", "MAR", "APR", "MAY"];
let arr2;
(function () {
    arr2 = [...arr1];
    arr1[0] = "potato";    
})();
console.log(arr2);
console.log(arr1);

Thanks

That is called an Immediately Invoked Function Expression (IIFE for short).

1 Like

This is the clear explanation I was hoping for.
Thanks a lot.