Always choose self-describing function names
Function names should start with a verb
Functions are supposed to do things.
And since verbs describe what is done, start your function name with the exact verb to describe what is going to happen.
- Bad:
var priceConvertor = function() {};
- Good:
var convertPrice = function() {};
- Better:
var convertCanadiantoAmericanDollars = function() {};
Use camelCase for functions
camelCase has all the words grouped together. It has the first word lowercase, and the first letter of all remaining words capitalized.
- Bad:
var Get_Location = function() {};
- Good:
var getLocation = function() {};
- Good:
var extractUserName = function() {};
Use CapsFirst and nouns for object constructors
Object constructors are for creating objects from a general template that have properties and methods attached to them.
By their nature, objects tend to be simple nouns.
- Bad:
var kitty = new kindOfAnimal();
- Good:
var kitty = new KindOfAnimal();
- Good:
var yaris = new Car();