it always good to have some standardized coding rules
use jshint
, JSHint
and .etc to create auto checker based on these rules
indentation 2 spaces
indentation type tab
- refer to usejsdoc
- put
'use strict';
on top. - use single qoute for string.
- function brackets put as the sample below.
- no restrict on having space after
=
- use flow to check javascript input type, (more details).
/**
* @flow
* @param {Object} arg1 - user credentials.
* @param {boolean} arg2 - login for 1 month.
* @return boolean
*/
function test(arg1, arg2) {
var string = 'test string'; // sample of string defination
var username = arg1.username,
password = arg1.password;
var login=
that.login(username, password, function(data){
return data.result;
});
return login;
}
- no
"..." + "..."
allowed in code when writing sql statement