Best Practices

Code Style

Variables names

This variable names doesn't make sense!

var a = 'gogo';
var b.variable = document.querySelector('.element');
var abc.set = 'set method from the abc object{}';
var foo = 'stil not clear enough';
var contactFormSubmitButton = document.querySelector('#submit-button');
var scrollToTopButton = document.querySelector('#scrolltotop');
var navigationListItems = document.querySelectorAll('.nav li');

This variable names make sense!

Code Style

Variables style

This variable names doesn't make sense!

var this-is-very-bad-naming;
var _this_is_not_gonna_make_me_happy;
var this is even worse with spaces;
var thisStyleIsMuchBetter;
var youCanReadThisBetterRight;
var _dontMakeItToLong;
var camelCaseStyle;

This variable names make sense!

Code Style

Variable & Function names

Don't use the same names for functions & variable

var isNumber = 5;

var isNumber = function(number) {
    return number * isNumber;
}

isNumber(isNumber);

Code Style

Always declare variables

var bodyTag, submitButtonContactForm, navigationListItems;

Code Style

Source

Made with Slides.com