Spread operator function

const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];

let arr2;

(function() {

"use strict";

arr2 = []; // change this line

})();

console.log(arr2);

what does the () at the end of the function execute. what is its importance

It allows the function to be an IIFE (Immediately Invoked Function Expression). This will cause the function to execute as soon as it is read. you can think of it as:

function nameOfFunction() {

“use strict”;

arr2 = ; // change this line
}

nameOfFuntion() //this does the same thing but you give it a name and execute it on a different line

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

Thanks bro,for your prompt reply
Respect