What does ${} (dollar sign and curly braces) mean in a string in Javascript? -
i haven't seen here or on mdn. i'm sure i'm missing something. there's got documentation on somewhere?
functionally, looks allows nest variable inside string without doing concatenation using +
operator. i'm looking documentation on feature.
example:
var string = 'this string'; console.log('insert string here: ${string}');
you're talking template literals.
they allow both multiline strings , string interpolation.
multiline strings:
console.log(`foo bar`); // foo // bar
string interpolation:
var foo = 'bar'; console.log(`let's meet @ ${foo}`); // let's meet @ bar
Comments
Post a Comment