Variables scope and when to use the $ sign
Hey guys,
I am trying to understand variable scoping in jQuery a bit more. What has always confused me is why some developers use the $ sign. when declaring variables and why some dont.
For example
- function($){
- function plugin(el, options) {
- this.defaults = {
- };
- this.$opts = $.extend({},this.defaults,options);
- this.$el = $(el);
- this.$arr = [];
- this.$group;
- this.$index;
- };
- .... on to functions
OR
- function($){
- function plugin(el, options) {
- this.defaults = {
- };
- };
- var var1, var2;
- .... on to functions
AND EVEN a combination of both
- function($){
- function plugin(el, options) {
- this.defaults = {
- };
- this.$opts = $.extend({},this.defaults,options);
- this.$el = $(el);
- this.$arr = [];
- this.$group;
- this.$index;
- };
- var var1, var2;
- .... on to functions
What is standard assuming there is one?
Thanks