Legacy String Methods for Generating HTML

I’m always really excited to see new methods on JavaScript primitives. These additions are acknowledgement that the language needs to evolve and that we’re doing exciting new things. That being said, I somehow just discovered some legacy String methods that you probably shouldn’t use but have existed forever. Let’s take a look! These legacy string […]

The post Legacy String Methods for Generating HTML appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh

I’m always really excited to see new methods on JavaScript primitives. These additions are acknowledgement that the language needs to evolve and that we’re doing exciting new things. That being said, I somehow just discovered some legacy String methods that you probably shouldn’t use but have existed forever. Let’s take a look!

These legacy string methods take a basic string of text and wrap it in a HTML tag of the same name:

"Hello".big() // "<big>Hello</big>"
"Hello".blink() // "<blink>Hello</blink>"
"Hello".bold() // "<b>Hello</b>"
"Hello".italics() // "<i>Hello</i>"
"Hello".link("https://davidwalsh.name") // "<a href="https://davidwalsh.name">Hello</a>"

Native prototypes don’t usually remove methods and for good reason — they can break websites! I’m shocked I didn’t know about these methods before today. It’s always fun to see relics of the web past though!

The post Legacy String Methods for Generating HTML appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh


Print Share Comment Cite Upload Translate Updates
APA

David Walsh | Sciencx (2022-04-26T11:04:50+00:00) Legacy String Methods for Generating HTML. Retrieved from https://www.scien.cx/2022/04/26/legacy-string-methods-for-generating-html/

MLA
" » Legacy String Methods for Generating HTML." David Walsh | Sciencx - Tuesday April 26, 2022, https://www.scien.cx/2022/04/26/legacy-string-methods-for-generating-html/
HARVARD
David Walsh | Sciencx Tuesday April 26, 2022 » Legacy String Methods for Generating HTML., viewed ,<https://www.scien.cx/2022/04/26/legacy-string-methods-for-generating-html/>
VANCOUVER
David Walsh | Sciencx - » Legacy String Methods for Generating HTML. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/26/legacy-string-methods-for-generating-html/
CHICAGO
" » Legacy String Methods for Generating HTML." David Walsh | Sciencx - Accessed . https://www.scien.cx/2022/04/26/legacy-string-methods-for-generating-html/
IEEE
" » Legacy String Methods for Generating HTML." David Walsh | Sciencx [Online]. Available: https://www.scien.cx/2022/04/26/legacy-string-methods-for-generating-html/. [Accessed: ]
rf:citation
» Legacy String Methods for Generating HTML | David Walsh | Sciencx | https://www.scien.cx/2022/04/26/legacy-string-methods-for-generating-html/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.