jQuery uses $ (dollarsign), is there a standard sign one can use for my own custom library? So that anyone would understand it’s custom?
Sometimes I only need to getEmementById and class, and be able to addclass and maybe a few more simple things. And I would like to do it like $(‘#someId’).addClass(‘foo’); but I would like for others who view the code, and myself, to understand that it is a custom library, not jQuery. So, is there a standard sign for this?
EDIT: I could use a namespace, but thats not as pretty as a single sign. And I cant see why there isn’t one out there allready that has been used by many before for this purpose. Isn’t there one?
A function must have a valid variable name.
Therefore, according to the spec a variable names can start with $, _, lower case/upper case unicode etc.
It’s probably best to use the module pattern inconjunction with IIFE though.
IE if your library was assigned to a variable ‘myLibrary’
And you could then pass it into an IIFE (Immediately invoked function expression) and give it your own variable – for instance using JQuery’s $
Because of the scope precedence of
$you’ll have no problem doing this – Unless of course you want to make use of jQuery