Expert Developer JavaScript Question:
Download Questions PDF

Mention what is the disadvantage of using innerHTML in JavaScript?

Expert JavaScript Developer Interview Question
Expert JavaScript Developer Interview Question

Answer:

If you use innerHTML in JavaScript the disadvantage is

► Content is replaced everywhere
► We cannot use like "appending to innerHTML"
► Even if you use +=like "innerHTML = innerHTML + 'html'" still the old content is replaced by html
► The entire innerHTML content is re-parsed and build into elements, therefore its much slower
► The innerHTML does not provide validation and therefore we can potentially insert valid and broken HTML in the document and break it

Download Expert JavaScript Developer Interview Questions And Answers PDF

Previous QuestionNext Question
What is the use of Void(0)?Which keyword is used to print the text in the screen?