I just came across this variation of appending a string containing a value stored in a variable, that I haven't seen before. Can anyone help me explain whats going on here?
This is what I came across:
var fruit = "banana";
$main = $('.main');
$main.append(`<p>${fruit} is a fruit.</p>`);
=> 'banana is a fruit.'
The slanted quotation marks seem to make a difference here, because this obviously doesn't do the trick:
$main.append('<p>$(fruit) is a fruit.</p>');
=> '$(fruit) is a fruit.'
It's probably something simple that I am not seeing right now. Can you explain to me, what's happening here? I couldn't find anything about these slanted quotation marks in Javascript/JQuery on the interwebs
Here is a simple Codepen to illustrate the issue: