+ 2
What does $ do in Javascript?
I see the $ symbol in Javascript web codes all the time and I'm wondering what it does.
3 ответов
+ 4
$ does nothing in javascript
unless any libraries or you!!!! defines it
such as jquery defined $ as selector for their jquery object
like $("textarea")
or variable's name but you just dunno what to name it. so you write
var $="Oops!";
and you dunno what to name again
var $="SOME MSG!";
also you dunno what to name it again
var $$="SOME CREEPY PASTA!";
That's really long
Just It's mean nothing unless it's was defined
+ 1
Oh yeah I forgot that. Da ES6!
0
A dollar sign followed with curly braces in template literals allows you to embed expressions within a string.
var x = 4, text = `x is: ${x}`;
// text === "x is: 4": True