Skip to content

Instantly share code, notes, and snippets.

@nielk
Last active August 29, 2015 14:02
Show Gist options
  • Save nielk/1fa2c0db873ebd05c51f to your computer and use it in GitHub Desktop.
Save nielk/1fa2c0db873ebd05c51f to your computer and use it in GitHub Desktop.
Javascript checklist

Javascript checklist

Legend:

☐ item

✔ item done

Checklist

☐ use 'use strict';

☐ avoid pollution of the global namespace by using IIFE :

var myModule = (function($, undefined){
 var myVar1 = '',
 myVar2 = '';

 var someFunction = function(){
   return myVar1 + " " + myVar2;
 };

 return {
   getMyVar1: function() { return myVar1; }, //myVar1 public getter
   setMyVar1: function(val) { myVar1 = val; }, //myVar1 public setter
   someFunction: someFunction //some function made public
 }
})(jQuery);

☐ Never declare a function in a non-function block (if, while, etc)

☐ Assign variables at the top of their scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment