Showing elements of an array without creating loop

The Spread Operator expands an array into its elements. It can also be used for object literals.

If we want to show a list of favorite foods without creating a loop function. Use a spread operator like this:

const fav= [ "Pizza", "fries", "Burger"];
console.log(...fav);

Leave a comment

Your email address will not be published. Required fields are marked *