-2

I've been learning JavaScript for not too long, and somethings that I notice a lot, but doesn't make sense to me are the different operators (if I can call them that) that defines a string. What I mean by that is the single quote ('), the double quote (") and the apostrophe-thing(`). I have come to realize that ``` is used when you want to use the variable or something (eg

console.log(`this is my string ${ str }`)

or something like that. I don't know too much about these and I would like to know what their different purposes are (or in the very least, what they are called)

Thanks!

P.S. I realize that this question topic causes some problems with the markdown. I have no idea how to fix it.

Skouzini
  • 143
  • 1
  • 10

1 Answers1

1

The apostrophe thing ` is general used for multi line strings while single and double quotes are used for single line strings. Single quotes are used to enclose double quotes.

For example: say I have a string like so: "I ate a fruit". If I want to print that string with the quotation marks I would use console.print(' "I ate a fruit" ').