Showing posts with label define. Show all posts
Showing posts with label define. Show all posts

Tuesday, April 29, 2014

Defining Functions With RequireJS

JavaScript is a functional language, where functions are first-class citizens. Sometimes, rather than trying to encapsulate all behaviour inside one object or another, it's easier to just define the function. Something I've found myself doing is defining an object whose only purpose is to hold references to my utility functions. So, other modules in my code will require this utility object, that has several functions attached to it, and may only use one of them. So why not define widely-used functions as AMD modules?