document.getElementById("demo").innerHTML += myObj[x] + "<br>";
document.getElementById("demo").innerHTML += myObj[x] + "<br>";
As you've seen in the previous question,
document.getElementById("demo")
serves to retrieve an element defined by id="demo"
from the DOM (the structure of the page, assembled according to the HTML).
Then
.innerHTML
retrieve a reference to the HTML that is inside this element. Then
+=
means "add at the end" a certain value ( a += b
equals a = a + b
in almost any language).
What's going to be added to the element is this:
myObj[x] + "<br>";
Since myObj[x]
is an array , that is, a collection of items. In this case, the added item will be taken from the variable x
.