"use strict"; // Script should not have many global objects. // One for one script is recommended. var APP = {}; APP.my_property = "I My Me Mine."; (function () { var a = 1, b = 2, sum = a + b, myObject = {}; // Declare all objects first as one line. function doForLoop() { var i = 0; myArray = [1, 2, 3], len = myArray.length; // Length of an array should be cached. for (i = 0; i < len; i += 1) { console.log(myArray[i]); } } function doForInLoop() { var i = 0, hasOwn = Object.prototype.hasOwnProperty; myHash = { one: 1, two: 2, three: 3 }; for (i in myHash) { // Loop only own properties but extended properties if (hasOwn.call(myHash, i)) { console.log(i, myHash[i]); } } } function doSwitch() { var unknown_numer = 0, result = ''; switch (unknown_number) { case 0: result = "zero"; break; case 1: result = "one"; break; default: result = "unknown"; } } function compareExactly() { var zero = 0; if (zero === "") { // Never be executed. } } });