Why is “element.innerHTML+=” bad code?
I have been told not to append stuff using element.innerHTML += ...
like this:
I have been told not to append stuff using element.innerHTML += ...
like this:
Whenever if there is any asynchronous task performing related to component and that component unmounts then React generally gives this warning –
A common antipattern in Python is to concatenate a sequence of strings using +
in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of CPython can apparently optimize this in some cases, but other implementations can’t, so programmers are discouraged from relying on this.) ''.join
is the right way to do this.
I discovered this pattern (or anti-pattern) and I am very happy with it.