This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 231
Home
Boris Yankov edited this page Jul 10, 2014
·
26 revisions
We use JSHint to enforce certain coding principles.
Include at the beginning of each .js file:
"use strict";
It is important that each statement is put in a closure like this (so the strict mode does not extend when bundling to files that are not intended):
(function(){
"use strict";
// All other code here
})();
More details on strict mode:
ECMAScript 5 Strict Mode, JSON, and More
It’s time to start using JavaScript strict mode
Variables that contain jquery selected elements should start with a '$'.
Don't:
var due = $('#due');
Do:
var $due = $('#due');
Use always, to prevent global variables:
(function () {
// ... all vars and functions are in this scope only
// still maintains access to all globals
}());