Should I be using (` - back tick) for all strings?


#1

Since I’ve discovered the backtick. Should we/I now be using this in place of all apostrophes and quotation marks?

It seems to work in place of quotation marks and apostrophes so am now wondering if I should be making it best practice to use the backtick for all relevant situations?

any help is greatly appreciated


#2

Backticks should not be used with Strings. Strings should be defined using double quotes, and in some cases, single quotes.


#3

thank you for clearing that one up. So just use back ticks when interpolating strings? ${}


#4

That’s correct. I believe it used to be more interchangeable with a single quote but it’s much more useful for more cleanly interpolating strings.


#5

Hi @bubbaspaarx,

Back tick is part of the ES6 syntax in JavaScript often referred as Template Literals. It has its own features of when to be used. Just sharing two links that might be useful for you, a bit in-depth but you can get the general idea:

The documentation:

Some explanation:
https://hacks.mozilla.org/2015/05/es6-in-depth-template-strings-2/

Enjoy your read. :slight_smile:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.