EcmaScript2017

Modern Internet Magazine About IT Industry

STRING TEMPLATES AND PADDING

String templates are one of my favorite ES6 features. They’re amazing! They make it easy to put variables into strings, which often comes handy. Just wrap something in backticks ` and you can insert any JavaScript code with ${...}. Just don’t get carried away.

In ES2017 we got string padding. I personally don’t use it, but if you remember the leftpad controversy … well, it seems a lot of people needed this 😅

You can use padStart to insert padding at the start of your string and padEnd to insert them at the end. We use start and end to support languages with different reading directions.