You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ian-Stewart-Binks edited this page Oct 4, 2014
·
21 revisions
#JavaScript Coding Style Guide#
###var###
No implicit var declarations.
No duplicate variable declarations or shadowing.
###Semicolons###
Always use semicolons. The JavaScript engine has the ability to infer semicolons, but omitting them is frowned upon.
###Spacing in equations###
Spacing in equations is necessary. var x=2+2*65/2 < var x = 2 + 2 * 65 / 2. (Parenthesis would be good in this situation to- but that's for a different style tip).
###Function spacing###
Put a double space in between function declarations.
###Variable naming###
CONSTANTS_ARE_IN_UPPERCASE.
The rest are in camelCase.
###jQuery selector caching###
Duplicated selectors can and often should be cached for efficiency.
#!javascript var circleObject = $("#circle");