TIL About .bold(), .blink(), and More JavaScript String Methods
Tags: todayilearned, javascript, webdev
Published: 2020-02-21 02:48:13

While playing around in the Chrome DevTools, I noticed a string method I had never seen before: `.bold()`. Curiosity got the better of me, and I gave it a try.

```js
let myString = 'Hello World!';
myString.bold(); // returns "<b>Hello World!</b>"
```

It's a method that returns the string wrapped in a `<b>` tag. It's **[very deprecated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/bold)**, but [all major browsers still support it](https://caniuse.com/#feat=mdn-javascript_builtins_string_bold).

`.bold()` is not alone - I've found several other string methods that are in the same boat. **Again, these are all deprecated, and should not be used in the wild.**

* **[`.anchor(name)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/anchor):** Returns the string wrapped in `<a>` tags with the `name` attribute set to the given name
* **[`.big()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/big):** Returns the string wrapped in [`<big>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/big) tags.
* **[`.fixed()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fixed):** Returns the string wrapped in [`<tt>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tt) tags.
* **[`.fontcolor(color)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fontcolor):** Returns the string wrapped in [`<font>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font) tags with the `color` attribute set to the given color
* **[`.fontsize(size)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fontsize):** Returns the string wrapped in [`<font>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font) tags with the `size` attribute set to the given size
* **[`.italics()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/italics):** Returns the string wrapped in `<i>` tags.
* **[`.link(url)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/link):** Returns the string wrapped in `<a>` tags with the `href` attribute set to the given URL
* **[`.small()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/small):** Returns the string wrapped in [`<small>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/small) tags.
* **[`.strike()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/strike):** Returns the string wrapped in `<strike>` tags.
* **[`.sub()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sub):** Returns the string wrapped in `<sub>` tags.
* **[`.sup()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/sup):** Returns the string wrapped in `<sup>` tags.

... and, of course, my personal favorite: **[`.blink()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/blink)**, which returns your string wrapped in a `<blink>`.

As with `.bold()`, these methods are all officially deprecated. Several of them even wrap your strings in _tags_ that have long since been deprecated. These methods remain in browsers for the sake of backwards compatibility, an artifact of development past.