Given an array of strings,
const bestRappers = ["Ice Cube", "MC Eiht", "Eazy-E"]
const output = document.getElementById('output')
/* 1: */ console.log(...bestRappers)
/* 2: */ output.innerText = [...bestRappers]
<p id="output"></p>
2 returns the items seperated by commas. 1 Isn´t seperated. Why?
What a spread operator does is take an iterable(in your case array) and give it as n number of arguments.
In first case console.log is a function so it gives it 3 arguments console.log(...bestRappers) ---> console.log(Ice Cube,MC Eiht,Eazy-E) so generally console.log function logs every argument space separated
In second case you spread the array into an array again ([...bestRappers]) so when you assign array to an innerText it displays as comma separated values
If you would like the same output in your console like in your dom then you have to use the JavaScript join() function with comma as seperator.
working example
bestRappers = ["Ice Cube", "MC Eiht", "Eazy-E"];
console.log(bestRappers.join(', '));
output.innerText = [...bestRappers]
<p id="output"></p>