Use meaningful names
Yes I know that you already know but honestly put meaningful name to a variable is not easy, just to remember that naming variable should be descriptive and usually javascript variable name write in camelCase
and for Boolean
variable name usually answer question such as isActive
or hasParams
// โ Don't
const x= "Jean Doe";
const bar= 23;
const active= true;
// โ
Do
const fullName= "Jean Doe";
const Age= 23;
const isActive=true;
No hardcode values
Hardcode is hard to maintain, instead of put constant values directly, you can put it inside a meaningful and searchable constants, by the way usually constant
write with SCREEEEEEEAM_SNAKE_CASE
function setConfig(hasKey=''){
...
};
// โ Don't
setConfig('KLKJFI123123KJHF');
// โ
Do
const HASH_KEY ='KLKJFI123123KJHF';
setConfig(HASH_KEY);
Avoid unnecessary
Don't add redundant context to variable that already describe itself, your code is already long enough
// โ Don't
const user:{
userId:'12345',
userPassword:'12345qwe',
userFirstName:'John',
userLastName:'Doe'
}
user.userPassword
// โ
Do
const user:{
Id:'12345',
Password:'12345qwe',
FirstName:'John',
LastName:'Doe'
}
user.Password
Top comments (0)