//===========================================================
// Separate var statements:
var a = 1;
var b = 2;
var foo = {
prop: 123
};
var bar = {
prop: 456
};
//put multiple comma-separated declarations in a single var statement, but only if they don’t have assignments
var foo, bar, baz;
//===========================================================
// Do use semicolons at the end of statements
// cause: please don’t intentionally make your code unreadable; I guarantee it will be unreadable enough without any extra help
//===========================================================
// console log breaks scripts in IE (if dev-panel is blocked/closed)
if(typeof console === "undefined"){
console = { log: function() { } }; // dummy console.log()
}
console.log("doc ready");
// read more: easy-to-use, cross-browser logging solution by Ben Alman
// "JavaScript Debug: A simple wrapper for console.log" ba-debug.js
//===========================================================
//
//===========================================================
// Be careful with "new Date(...)"
var d = new Date("February 31, 2014 00:00:00"); // => Mon Mar 03 2014 00:00:00
var d = new Date("February 32, 2014 00:00:00"); // => Invalid Date
var dat = new Date(2014, 01, 31); // => Mon Mar 03 2014 00:00:00
var dat = new Date(2014, 01, 32); // => Mon Mar 04 2014 00:00:00
var dat = new Date(2014, 01, 302);// => Sat Nov 29 2014 00:00:00
//===========================================================
// Allow for configuration and translation
//???????????????????? try it sometime http://www.w3.org/wiki/JavaScript_best_practices
//===========================================================
// Modularize - one function per task
// So do use Facade ( function init() { calls all the other stuff } )
// Function should have one way in & one way out
// Use & create Helper...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.