Mention what is the disadvantage of using innerHTML in JavaScript?

0

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

asked Apr 14, 2023 at 19:53
Sign in to add a comment

0 Answers

0
📝 No answers yet!

Be the first to answer this interview question.

Your Answer

Sign in to post your answer and help the community.