Last active
December 6, 2022 15:32
-
-
Save christinach/6f82f088ad3b5bdd9f4d1136249b4435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Variables: | |
Avoid global variables: | |
Variables can be accessed in local scope or global scope. | |
Local and global variable with the same name => javascript will prioritize the local variable. | |
Local variables are deleted once the local execution context is complete. Global variables | |
References | |
Use const or let for references | |
Avoid using var (https://developer.mozilla.org/en-US/docs/Glossary/Hoisting) | |
Functions: | |
Arrow function | |
Is a function expression not a function declaration | |
Cannot use a constructor. Is not called with new. Does not use 'this'. | |
Few characters shorter | |
Basic function | |
Name conventions: | |
Files | |
Functions | |
Class | |
Destructuring | |
Object | |
Array | |
Recursion | |
Avoid nesting more than two levels. It can be difficult to follow. | |
Comments | |
Use multi-line comment as: /** .... */ | |
Use single line comment as: // | |
JS features that would like to use | |
Optional chaining operator | |
Semicolons | |
Use semicolons. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#automatic_semicolon_insertion | |
References: | |
https://eslint.org/docs/latest/rules/ | |
https://arcticicestudio.github.io/styleguide-javascript/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment