Template Literals are Strictly Better Strings

Avatar of Chris Coyier
Chris Coyier on

Nicolás Bevacqua wrote this a year ago, and I’d say with a year behind us he’s even more right. Template literals are always better. You don’t have to screw around with concatenation. You don’t have to screw around with escaping other quotes. You don’t have to screw around with multiline. We should use them all the time, and adjust our linting to help us develop that muscle memory.

Besides the few things you can’t use them for (e.g. JSON), there is also the matter of browser support. It’s good, but no IE 11 for example. You’re very likely preprocessing your JavaScript with Babel anyway, and if you’re really smart, making two bundles.

Direct Link →