this is quite an easy question but is not obvious to me.
What is the difference between this:
function fesElsDeures(subject){
console.log(`just started doing my ${subject} `);
}
and this:
function fesElsDeures(subject){
console.log("just started doing my ${subject} ");
}
It seems that in the second option, my console does not recognise the subject as a different value.
Thanks!
this is quite an easy question but is not obvious to me.
What is the difference between this:
function fesElsDeures(subject){
console.log(`just started doing my ${subject} `);
}
and this:
function fesElsDeures(subject){
console.log("just started doing my ${subject} ");
}
It seems that in the second option, my console does not recognise the subject as a different value.
Thanks!
Share Improve this question edited Jun 25, 2019 at 10:19 user330315 asked Jun 25, 2019 at 9:09 Lídia PelejàLídia Pelejà 691 silver badge5 bronze badges2 Answers
Reset to default 5Double quotes or single qoutes are just indicating string. But in first example there are not single quotes. It's a back-tick (`
`
) and it allows you to use embedded expression( in this case 'subject' parameter of your function).
https://developer.mozilla/en-US/docs/Web/JavaScript/Reference/Template_literals
Don't to be confuse with ' (Single quote) with ` (back-tick).
- " is Double quotes,
- ' is single quotes
- ` is back-tick.
when you use back-tick, it allows you write multi line texts. Template literals