JavaScript Coding Convention
Last updated
Was this helpful?
Last updated
Was this helpful?
A convention to standardize JavaScript coding style.
We are not reinventing the wheels. We adopt from and adjust accordingly to our preferences.
In this document, we will rewrite the selected specification we adopt and add a few of our preferences. For anything that is not stated in this document, refer to AirBnB JavaScript Style Guide.
2.1 Use const
for all of your references; avoid using var
. eslint: ,
Why? This ensures that you can’t reassign your references, which can lead to bugs and difficult to comprehend code.
2.2 If you must reassign references, use let
instead of var
. eslint:
Why?
let
is block-scoped rather than function-scoped likevar
.
Why? It is shorter and descriptive.
To be continued. More to come
3.1 Use the literal syntax for object creation. eslint:
3.3 Use object method shorthand. eslint:
3.4 Use property value shorthand. eslint: