Skip to content

Instantly share code, notes, and snippets.

@ZachMoreno
Last active August 29, 2015 14:13
Show Gist options
  • Save ZachMoreno/76507b9df4dbe0e1866f to your computer and use it in GitHub Desktop.
Save ZachMoreno/76507b9df4dbe0e1866f to your computer and use it in GitHub Desktop.
JS Library Scaffold
var LibraryName = (function () {
var LibraryName = function LibraryName() {
}
// Todd Moto's forEach method
LibraryName.forEach = function forEach(array, callback, scope) {
for (var i = 0; i < array.length; i++) {
callback.call(scope, i, array[i]); // passes back stuff we need
}
}
// Mozilla's getMaxOfArray method
LibraryName.getMaxOfArray = function getMaxOfArray(numArray) {
return Math.max.apply(null, numArray);
}
// Custom method
LibraryName.customFunction = function customFunction() {
// ...
}
// http://stackoverflow.com/questions/15174187/properties-of-javascript-function-objects
// LibraryName.prototype = {
// greet: function () {
// console.log('Hello, my name is ' + this.name);
// }
// };
return LibraryName;
})();
jQuery(document).ready(function() {
LibraryName.customFunction();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment