Skip to content

Instantly share code, notes, and snippets.

@benjaminsinger
Created October 28, 2014 17:35
Show Gist options
  • Save benjaminsinger/3eefe5377da59098590f to your computer and use it in GitHub Desktop.
Save benjaminsinger/3eefe5377da59098590f to your computer and use it in GitHub Desktop.
This is what a clean JS file looks like -- do it like this in future.
// "use strict";
var $home = (function () {
var home = {}, // create the 'global local' -- within our primary home function -- app object {}
saywhit = "you wot mayte?",
isTouch = $('.touch').length,
isIE8andBelow = $('.lt-ie9').length,
hasCssAnimations = $('.csstransforms').length,
siteH, siteW,
body = $('body');
windowMain = $(window);
home.thisIsTheMainObject = function () {
var thisIsTheMainObject = {};
thisIsTheMainObject.init = function() {
window.console.log(saywhit + ' this is the saywhit variable');
}
thisIsTheMainObject.spin = function() {
window.console.log('spin it');
}
window.alert('cannot');
return thisIsTheMainObject;
}();
home.init = function () {
home.thisIsTheMainObject;
// home.thisIsTheMainObject.spinit();
};
return home; // must return app; for contents of app {} object to be accessible to browser
})();
$(function(){
$home.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment