Skip to main content

Javascript best practices

Summary

  • Naming camelCase variable, function and PascalCase for classes.

  • Descriptive variable names for variables, functions and classes.

  • Comment (Why not what), Comment block for functions, classes, modules

  • Immutability

  • The scope of variables

  • a function = a task and as short as possible

  • Error handling

  • Types and equality

  • Avoid global variables, use modules / IIFE

  • arrow function

  • Asynchronous

  • management of DOM events

  • linter

  • Security

  • Debug

  • Transpilation