One of the most popular languages to learn is JavaScript. "If you're only going to learn one programming language, learn JavaScript," as many people advise. In an interview, Quincy Larson, the founder of FreeCodeCamp, was asked which language develop...
abhirajb.hashnode.dev11 min read
hi Abhirajb,
I am not able to understand why you are assigning immediately invoking function to this function, and you are passing el argument to the function, what does the el refer to?
const arrayToHtmlList = (arr, listID) =>
(el => (
(el = document.querySelector('#' + listID)),
(el.innerHTML += arr.map(item => <li>${item}</li>).join(''))
))();
Wouldn't a simple function as follows serve the same purpose?
const arrayToList = (arr, list)=>{
let el = document.getElementById(list);
arr.forEach(item=>el.innerHTML+=<li>${item}</li>)
}
Muhammad Ozair
Very knowledgeable