Write code as sort as possible
Don't write code too short because it's make other developers hard to understand, look at this code below
‘?’ i = i ? i < 0 ? Math.max(0, len + i) : i : 0; 
Can you guessed value of variable I? If someone find this code he will spend his entire life just to find that variable i value is 0.
One letter variable
Don't name you variable with a, b, c or d, a short variable name because it's hard to find and search by editor, and even if we already found it we can't understand "the true meaning" of this variable until we analyze the code line by line.
Use meaningless abbreviation
Don't name your variable with a meaningless abbreviation
 list → lst
 begin_date →bgdt
 browser → bws
Instead of dteofbrth you can use dob as abbreviation of date of birth, it will help a lot in the future.
Being abstract
Don't use abstract name such as obj, value, data, elem as your variable name unless it's is necessary, it's hard to define data variable if we use more than one data, and what is data or value mean either? everything has data and value
Instead you can use userData or customerData to define more meaningful variable name
Super function
Don't create a function that has many functionality, a good function only do one thing, validateEmail(email) function should only validate email format not to send or pre-fill email value, you can create other function to do that.
Inconsistent
If you define showFirstName function to preview first name value then don't define displayLastName as function to preview last name value, it's confusing and hard to debug when our code is getting bigger, be consistent with your prefix
Instead of displayLastName you can define your function with showLastName, be consistent
Use reusable name
Don't reuse a variable name that already set, because it's hard to know the actual value when we use it at multiple place
    
Top comments (0)