As you can see in local scope of the function, the value of list is an Array but when I type list in console it return a DOM element. I don't understand this behaviour.
2 Answers
In console list return with a ID of list. And if any variable declared inside a function,it only accessible by that function,it will not available outside of this function. Please read this doc to know further more about function

listreturn with a ID oflist. And if any variable declared inside a function,it only accessible by that function,it will not available outside of this function.listin your console, which @MuhammadAmirozzamanNiaz is correct, it does not get evaluated the same.. Inside your function, right before you dolist.mapyou should put aconsole.log(list)so that it gets evaluated appropriately.