Bad:
Good:
function hashIt(data) {
let hash = 0;
const length = data.length;
const char = data.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
// Convert to 32-bit integer
hash &= hash;
}
}
Version control exists for a reason. Leave old code in your history.
Good:
doStuff();
Remember, use version control! There’s no need for dead code, commented code,
and especially journal comments. Use git log
to get history!
Bad:
function combine(a, b) {
}
They usually just add noise. Let the functions and variable names along with the
proper indentation and formatting give the visual structure to your code.
Bad:
Good:
$scope.model = {
menu: 'foo',
nav: 'bar'
};
const actions = function() {
};