General Rules
Master essential JavaScript writing rules, including semicolon usage, spacing, and statement formatting.
General Rules in Writing JavaScript
Semicolons (;) are used to separate JavaScript statement therefore, every statement should have a semicolon at the end.
Multiple statements can be allowed to be written in one line when separated by semicolons.
JavaScript ignores multiple spaces. Users can add white space to the script to make it more readable.
A good practice is to put spaces around operators (= + - * /)
.
We can use the +
symbol for concatenation.
We can insert HTML codes in JavaScript outputs.
JavaScript code can be grouped together in blocks by placing them inside curly brackets.
Edit on GitHub
Last updated on