what $ means in the javascript

  • Thread starter Thread starter Victor
  • Start date Start date
V

Victor

i found some example js. the character $ has been used a lot. What's that
mean? can someone give me some reference on that?

Thanks
 
It's part of regex but it might be used in the name of a function or
variable. Variables names can begin with a character, $ or an
underscore.
 
Hello,

In the context of AJAX or Protype JavaScript framework
(http://www.prototypejs.org), $ is a shortcut for document.getElementById()
function. For example, $('titleTag') means document.getElementById
('titleTag').

Hope this helps?
 
Hi Victor,

For the '$' dollar sign, if what you mean is the '$' in javascript property
name or variable name(javascript allowed them to start with dollar sign),
it maybe the code convention of the author.

Also, '$' will also be used as special character in regular expression:

http://www.trans4mind.com/personal_development/JavaScript/Regular Expressi
ons%20Simple%20Usage.htm

http://www.devguru.com/Technologies/ecmaScript/quickref/regexp_special_chara
cters.html

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Victor,

Have you got any further idea on this issue? If you have any further
questions or anything else we can help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi guys:
thanks for all responses. but i am getting a little bit confused now.
The reason I raise this question is in some examples about ms ajax extesion
programming, I saw some function name like $find $object. But these
functions can not be found among those standard js fuction. I think these
should be some kinds of the code convention for the author?
Or these function is just for ms ajax extension? am i rite about this?

For the prototype javascript. I think it should a different framework than
the ms ajax extension rite?

cheers
Victor
 
Thanks for your reply Victor,

Yes, for the Microsoft AJAX script library, it has many method or variables
that contains '$' char in their names. This is just the naming convention
as the AJAX library will adopt a namespace naming convention for the class
and variables. e.g.

Sys$Enum$toString

Sys$Component$_setProperties

Sys$UI$DomElement$getLocation

You can download the Microsoft AJAX script library and check the
function/variables defined there:

http://ajax.asp.net/downloads/library/default.aspx?tabid=47&subtabid=471

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top