Expert Developer JavaScript Question: Download Questions PDF
What is the disadvantages using innerHTML in JavaScript?
![Expert JavaScript Developer Interview Answer Expert JavaScript Developer Interview Question](https://globalguideline.com/public/images/interview/22.png)
Answer:
► If you use innerHTML the content is replaced everytime.
► We cannot use like 'appending to innerHTML'.
► Even if we use += like "innerHTML = innerHTML + 'html'" then also the old content is replaced by html.
► If we use innerHTML then the entire innerHTML content is re-parsed and build into elements. Therefore it's much slower.
► The innerHTML doesn't provide validation and therefore we can potentially insert invalid and broken HTML in the document and break it.
► We cannot use like 'appending to innerHTML'.
► Even if we use += like "innerHTML = innerHTML + 'html'" then also the old content is replaced by html.
► If we use innerHTML then the entire innerHTML content is re-parsed and build into elements. Therefore it's much slower.
► The innerHTML doesn't provide validation and therefore we can potentially insert invalid and broken HTML in the document and break it.
Download Expert JavaScript Developer Interview Questions And Answers
PDF
Previous Question | Next Question |
What is the difference between Scripting and Programming? | What would "1"+2+3 and 1+2+"3" evaluate to, respectively? |