Skip to content

Javascript Code Review Checklist

Checklist Pointers

Sr No.Check
1Choose easy to understand and short names for variables and functions.
2Try using closures and the module pattern.
3Use linting to verify your code.
4Comment what you consider needed (/* */ is much safer to use because it doesn’t cause errors when the line break is removed.).
5Use Shortcut Notations.
6Write smaller, generic helper functions that fulfill one specific task rather than catch-all methods.
7Avoid heavy nesting.
8Keep computation-heavy code outside of loops.
9Keep DOM Access to a Minimum.
10Don’t trust that data reaches your function is of the right format.Test with typeof and then do something with it.
11Don’t expect elements in the DOM to be available.Test for them and that they indeed are what you expect them to be before altering them.
12Never ever use JavaScript to protect something.
13Use single quotation marks for string declarations.
14Keep indentation as 2.
15No js inline code has to be present in html.
16Collate, minify and optimize your code in a build process.
17JavaScript files are loaded asynchronously using async or deferred using defer attribute.
19Use of if, if else, else if, switch should be used properly. Avoid too many nested if else statements, instead go for switch-case.
20const and let should be used based on their definition.
21Functions should hardly ever be 20 - 40 lines long.
18Add parameter description for every function parameter as a part of comments.
22Proper use of HOF (Higher order functions.).
23Every method/function should have a try-catch block to avoid run time errors.
24Use loggers in the catch block to get exact error.
25Verify if business logic is proper and written efficiently.
26Function casing.
28Using spread operator.
29Be consistent in your usage of arrow function.
30Use destructuring assignment for arrays and objects.
27Variable casing.
31Use Promises or Async/Await. Rejection is handled.
32No syntax/runtime errors and warnings in the code.
33No deprecated functions in the code.
34Check that each function is doing only a single thing.
35No magic numbers. Put all such numbers as a constant.
36Make sure recursive function don’t end up in infinite loop.
37Avoid inline styling through JS use classes instead.
38make sure the whole script wrapped inside document ready.
39Use meaningful names for variables and function.
40Add proper commenting.
41Try using deffer while loading Scripts to avoid render blocking resources issue in the performance.
42Make sure there is no message/error present in the console.
43Please make sure to use condition while using offset().top property if the offset is present then only use top or else it will throw an error in the console.
44Form/Input validation is not just to add required attribute also validate the input via JS to make sure expected input is entered by user.