Alex Rivera | Logout

Why use $ (dollar sign) in the name of javascript variables?

Asked 2010-07-29T09:02:04.887
57

Possible Duplicates:
Why would a javascript variable start with a dollar sign?
JQuery : What is the difference between “var test” and “var $test”

What is the difference between this two ways of initializing variables?

var $val = 'something'

     OR

var val = 'something'

as I see they are the same thing.

Maybe in this case $ is only the part of name in variable? (it will become a meaningless question in that case:/)

Thanks

Edit
Report

2 Answers

12

You are correct. $ is a part of the name of the variable.
This is not perl or PHP :)

answered 2010-07-29T09:03:46.820
3

syom - in my case, i use the $ prefix to indicate that it's a variable that is referenced by jquery. It's purely a part of the variable and not a reserved character.

keeps it easy to identify in long code runs..

jim

answered 2010-07-29T09:03:50.487

Your Answer