0

When you pass variables in Javascript functions, what is the difference between '$name' and 'name'.

For example,

var myFunction = function(name){
  name.a = "a"; 
};

var myFunction = function($name){
  $name.b = "b";
}; 
Hyun Jung
  • 69
  • 2
  • 10
  • 1
    There's no difference. `$` is a valid character for use in a parameter or variable name, but it has no special meaning. It's not an operator. – nnnnnn Mar 21 '17 at 02:28

1 Answers1

1

The only difference in your example is the name, it has no special purpose.

However you might have seen the $name styled variables in jQuery examples in which it's normal to name selected elements ($('a')) as, for example, $links.

E. Sundin
  • 3,658
  • 16
  • 27