Theoretically, this is the most optimized you can get.
BUT, if we use TypeScript, and go the mathematical route of only using one letter per var-name, we get this:
However, (to me) this looks like the end of the road for refactorization, I don't think we can make this any smaller,- and if you can, it's because of a very niche detail.
But I think this is the best optimization from the original function.
understandable and readable is very hard in your solution.
Refactor is not to get code smaller.
I prefer === checks instead ==
I prefer !?.length instead l.length == 0
According to w3 guidelines, a space should be included before the trailing / and > of empty elements, for example, <br />. These guidelines are for XHTML documents to render on existing HTML user agents.
According to w3 guidelines, a space should be included before the trailing / and > of empty elements, for example, <br />. These guidelines are for XHTML documents to render on existing HTML user agents.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Rerefactor based on Keff's answer.
Theoretically, this is the most optimized you can get.
BUT, if we use TypeScript, and go the mathematical route of only using one letter per var-name, we get this:
Assuming people use the correct types in JS, as if we we're in a strongly typed language, we get the final result of:
But, we can make
e
a one-time expression:LOOK! It's a 2-liner! :O
However, (to me) this looks like the end of the road for refactorization, I don't think we can make this any smaller,- and if you can, it's because of a very niche detail.
But I think this is the best optimization from the original function.
understandable and readable is very hard in your solution.
Refactor is not to get code smaller.
I prefer === checks instead ==
I prefer
!?.length
insteadl.length == 0
According to w3 guidelines, a space should be included before the trailing / and > of empty elements, for example,
<br />
. These guidelines are for XHTML documents to render on existing HTML user agents.edited
Then I think the people who submitted those one-liners (Which are even harder to understand than my code!) misunderstood the point. :p
the one line solutions with nested ternary expressions are also difficult to understand.
Goals for refactoring code: readability, understandability, maintainability, performance, usage of latest code style / programming / functions / methods
I don't think your example works as intended.
Also, why is that? Does the space do something to make the HTML more understandable to some interpreters?
edited my comment
According to w3 guidelines, a space should be included before the trailing / and > of empty elements, for example,
<br />
. These guidelines are for XHTML documents to render on existing HTML user agents.