Question 14
Back to Exercise
What is the hidden cost of list.innerHTML += "<li>New</li>"?
- A Every existing child is re-parsed and re-created, so their listeners and state are lost Correct
- B Nothing – it only adds one element
- C It throws in strict mode
- D It adds the item at the start
Correct Answer: Option A
It reads the HTML as a string, appends to it and parses everything again. Use append or insertAdjacentHTML.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!