-2

I started learning JavaScript, and I have faced this problem with strings.

the problem is

` is not '

and the result is

` is not '

Why are the results different?

dotnetCarpenter
  • 10,019
  • 6
  • 32
  • 54
B. Okba
  • 1,021
  • 12
  • 16
  • 5
    It's not clear what you are asking. You clearly know how to type the two different quote marks, so what do you mean by "how can I write..." – Mark Dec 04 '19 at 19:21
  • Those are different characters and thus have different syntax meaning. Just like `=` is not the same as `!` so `\`` is not the same as `'`. – Igor Dec 04 '19 at 19:21
  • By using another key on your keyboard? I'm not sure to understand the question... – Laurent S. Dec 04 '19 at 19:23
  • Duplicate of https://stackoverflow.com/q/9549780/1260204 or https://stackoverflow.com/q/36107981/1260204 or https://stackoverflow.com/q/27678052/1260204 – Igor Dec 04 '19 at 19:24
  • You can learn more about the differences on MDN, they are called [Template Literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) – Narm Dec 04 '19 at 19:24

1 Answers1

1

`` - this is 'backtick' - when you use those characters, this is template string. This syntax allows you, to use for example, multiline strings or nested js variables ${}.

'' or "" - this is standard js syntax for strings, you cannot use here ${}

Kamil Naja
  • 6,267
  • 6
  • 33
  • 47