Good for simple strings.
var text = "Hello!";
console.log(text);Output:
Hello!Can be used to include single quotes.
var text = "How's it going?";
console.log(text);Output:
How's it going?You can also include double quotes in double quotes!, however they must be escaped (prefixed) by a backslash \.
var text = "\"What's going on?\"";
console.log(text);Output:
"What's going on?"Also good for simple strings!
var text = 'What?';
console.log(text);Output:
What?You can put doubles in singles!
var text = '"Oh!"';
console.log(text);Output:
"Oh!"And conversely to doubles, you can put singles in singles, but they need to be escaped as well.
var text = '\'Right!\'';
console.log(text);Output:
'Right!'The most powerful of the three, can be used for simple strings as well.
var text = `I am teaching margo about syntax stuff`;
console.log(text);Output:
I am teaching margo about syntax stuff;What makes it powerful? You can insert variables directly into the string!
var lovely_individual = "Margo";
var text = `Hello, ${lovely_individual}!`;
console.log(text);Output:
Hello, Margo!Of course, you can escape these as well
var text = `I am not \`quite\` sure when you would need this.`;
console.log(text);Output:
I am not `quite` sure when you would need this.Now for the magic!
To get some properly formatted quotes for writing....
var text = `“here’s an example,” he said.`;
console.log(text);Output:
“here’s an example,” he said.Hope this helps! 😊