4 ms·
I feel like you've accidentally made the article's point here.. if you want left pad: str.padStart(10) Which has broad browser compatibility[0] and 97.27% r
by gnabgib 2y ago
I feel like you've accidentally made the article's point here.. if you want left pad:
str.padStart(10)
Which has broad browser compatibility[0] and 97.27% real-use support[1].
In some ways you're skipping the library step (no `npm install`) but you're also embedding library fragments in your code via these generated answers. If there are security implications or bugs in those fragments, or they're outdated - you're unlikely to see/be notified. If you used a library you'll see updates / notifications or dependency warnings in your build pipeline (depending on your setup). Those updates aren't risk free (protest-ware, abandon-ware, malicious updates) but if it's an area you're not familiar with/don't wish to research they provide more value than solves it for now.
[0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
[1]: https://caniuse.com/?search=padStart https://caniuse.com/?search=padStart
- simonw 2y agoHah, fair enough! Left-pad was a terrible example to pick there.
- gnabgib 2y agoPerhaps, but great from the "everyone knows the issue" point of view :D 2016 is far enough back I suppose there are going to be devs who don't know the reference (they've never had the pleasure of IE support, more's the pity)