19

why $ symbol is used in javascript? i want to know what it specify?

David
  • 188,958
  • 33
  • 188
  • 262
Ajay Yadav
  • 1,603
  • 4
  • 17
  • 28
  • 6
    In what context? Can you provide some Javascript code snippet involving a `$` in your question? If you're talking about code like `$("#data[select]").val();`, then it's probably jQuery, but that's not necessarily true in all cases. – In silico Apr 24 '11 at 00:22
  • Without context (where did you see it used?) this question cannot be reasonably answered. Voting to close as 'not a real question.' – David Thomas Apr 24 '11 at 00:23
  • 4
    `$` is a legal character for a variable name in JS. It's often used as a shorthand version of something you call a lot, like the jQuery object. You can use it for wvatever you want. Same happens with the `_` character in PHP (it's an alias for the `gettext()` function). – mingos Apr 24 '11 at 00:26
  • 1
    Possible duplicate: http://stackoverflow.com/questions/3107543/what-is-the-symbol-used-for-in-javascript – malgca Aug 31 '13 at 13:16

3 Answers3

16

You may be looking at jQuery code. $ is a variable (in jQuery's case it's a shortcut for 'jQuery').

Paul
  • 2,146
  • 18
  • 26
6

You may well be looking at JavaScript written by a PHP programmer!

Christo
  • 8,181
  • 2
  • 20
  • 16
3

It's used as a namespace in jQuery. It's also a pseudonym for the jquery object .

duffymo
  • 299,921
  • 44
  • 364
  • 552