For better readability, avoid lines longer than 80 characters.
If a JavaScript statement doesn’t fit on one line, it’s best to break it after an operator or a comma.
document.getElementById(“demo”).innerHTML = “Hello Dolly.”; |
Always maintain consistency in your naming conventions across your code. For example:
The choice between hyphens, camelCase, or underscores for variable names is often debated among programmers. The answer depends on who you ask:
In HTML and CSS:
Underscores:
Many programmers prefer using underscores (e.g., date_of_birth
), particularly in SQL databases.
Underscores are also common in PHP documentation.
PascalCase:
PascalCase is commonly used by C programmers.
camelCase:
camelCase is the standard naming convention in JavaScript itself, as well as in libraries like jQuery and others.
Avoid starting names with a $ sign, as it may conflict with the naming conventions of many JavaScript libraries. |