Why bother using apostrophes or quotation marks for setting strings if backticks exist?

Hi all, newcomer to the programming scene.
I have been studying JavaScript lately and what I cannot grasp is why would I ever bother encasing strings in ’ string’ or “string” when I can use string and embed variables and all other symbols without the need for /’ while I’m at it?
Is this part of legacy code or does encasing string in backticks sometimes not work ?

well, looking at the support for template literals:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

(at the bottom is a browser compatibility table), we can see that Internet Explorer doesn’t support template literals, so if your website needs to support IE, you either: need to transpile (using bable for example) or not use template literals.

The first options (bundling and transpiling) is a lot more common.

The problem with JS is that they can’t make breaking changes. Breaking the web would be catastrophic. And some people just don’t update there browsers (so frustrating)

2 Likes

Thanks, I guess this makes sense. So, in general, for coding outside of web development, backticks won’t cause any issue?

backticks are a javascript specific concept, how are you going to use that outside of web development?

Many language do have similar features, although sometimes named differently. Python also has template literals concept (named f-string), which was introduced in python3.6, so if you wrote a program in python which needs to support python3.5 and earlier, you can’t use f-string