+ 2

What does $ do in Javascript?

I see the $ symbol in Javascript web codes all the time and I'm wondering what it does.

1st Oct 2018, 5:57 AM
Sir White Cat
Sir White Cat - avatar
3 Réponses
+ 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
1st Oct 2018, 6:09 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 1
Oh yeah I forgot that. Da ES6!
8th Oct 2018, 12:26 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
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
1st Oct 2018, 10:41 AM
Hoàng Nguyễn Văn
Hoàng Nguyễn Văn - avatar