January 2020
Intermediate to advanced
548 pages
13h 36m
English
To illustrate this challenge, consider a simple shopping list in the form of an array composed of individual items as strings:
const shoppingList = ['Bananas', 'Apples', 'Chocolate'];
Deriving a DOM tree from this data is quite simple:
const ul = document.createElement('ul');shoppingList.forEach(item => { const li = ul.appendChild(document.createElement('li')); li.textContent = item;});document.body.appendChild(ul);
This code would produce the following DOM tree (and append it to <body>):
<ul> <li>Bananas</li> <li>Apples</li> <li>Chocolate</li></ul>
But what happens if our data changes? And what would happen if there were <input> via which users could add new items? To accommodate these things, we would have to implement ...
Read now
Unlock full access