JavaScript: Is there a utils library? [closed]

I'm wondering if such a library exists, where the library contains only a collection of common utility functions such as trim, indexOf (for arrays), map, each, typeOf and so on...

I'm aware that jQuery provides some of the functions I listed above, but I'm looking for something that is designed purely for this (I really don't need jQuery on the server-side running node.js for instance, nor do I want to depend on it if I'm writing a non-jQuery-related JavaScript library). I've recently begun collecting an assortment of these functions for future copy/pasting, but my guess is that there are many others that I won't even know to look for, or think of using, unless someone presents them to me.



The functions you mention are all standard in ECMAScript 5. And this library implements them in such a way that you can use them in older browsers/JavaScript versions as well, in a way that will be compatible when your environment catches up with the standard:


I'm fond of underscore.js; it doesn't provide string utilities such as trim; it's focused on object-oriented and functional utilities, including all of the other things you mention. Another nice thing about it is that it doesn't reference the DOM at all, so it's useful for javascript programming that isn't web-based or DOM related.


Boiler.js is an up and coming utility library that offers many useful JavaScript utilities and is a direct competitor with Underscore.js.


jQuery provides all of those and many more, you would be better off just using it.

jQuery can sit side-by-side with other frameworks, so can be independent if another framework is present.

See: jQuery Utilities Documentation


Javascript itself has many of these functions built into the basic types. Before building your own, perhaps a copy of JavaScript: The Definitive Guide, focusing on the API reference in the back, would do you some solid good.

After that investigate frameworks, or at least being looking into how you can create your own framework for your functions (as opposed to copying and pasting). Here the module pattern would be helpful to you.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.