Jan 31 20231 min read
Blogs
Superficial guide to naming variables (JS/TS)
- Boolean variables - use a helping verb as a prefix
- Ex.
isChecked
,isOpen
,willToggle
- Ex.
- Function names - use a verb as a prefix
- Ex.
checkIsValid
,submitPost
,fetchPost
- Ex.
- Keep variable names descriptive enough
- Declaring variables
- Use
const
for declaring by default - Use
let
if variable is going to be reassigned - Never use
var
- Use
- Its okay if variable names are long