-4

Are there any JS libraries that use $ in the same way as Jquery uses it? I searched all over the internet to my capabilities and i couldn't find any use cases where there is a possibility for conflict over the usage of $ in jquery.

1 Answers1

1

There really are quite a few. MooTools is one example, but there are many others as well. The $ character is used so frequently in JS shorthand because it very commonly has special significance in other programming languages, but is free from such associations in JS. So library developers will often use the $ character as a shortcut to their library.

This really isn't a big deal if you're writing well formatted JS. Any time you write a block of JS that relies heavily on a partiular library that uses a common shortcut, you should wrap it in an Immediately Invoked Function Expression that gives you full access to the shortcut while simultaneously preventing both conflicts and scope issues.

(function ($) {
    // use the $ within this function with impunity.
    // there is no danger of it conflicting with another library here.
    $('body').doStuff();
})(jQuery);
Ben
  • 316
  • 1
  • 7