Loading Please Wait...
Always use the same coding conventions for all your JavaScript projects.
Coding conventions are style guidelines for programming. They typically cover:
Coding conventions secure quality:
Coding conventions can be documented rules for teams to follow, or just be your individual coding practice.
Always use the same naming convention for all your code.
Many programmers prefer to use underscores (date_of_birth), especially in SQL databases.
PascalCase is often preferred by C programmers.
camelCase is used by JavaScript itself, by jQuery, and other JavaScript libraries.
first_name = "Lynxsia"; // underscore
lastName = "IT Solutions";// camel case
FullName = "Lynxsia IT Solutions"; // pascal case
Always put spaces around operators ( = + - * / ), and after commas.
let x = y + z;
const myArray = ["Volvo", "Saab", "Fiat"];
Always use indentation (2 or 4 spaces) of code blocks.
function toCelsius(fahrenheit) {
return (5 / 9) * (fahrenheit - 32);
}
General rules for simple statements:
const cars = ["Volvo", "Saab", "Fiat"];
const person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};
General rules for complex (compound) statements:
function toCelsius(fahrenheit) {
return (5 / 9) * (fahrenheit - 32);
}
General rules for object definitions:
// Short
const person = {firstName:"John", lastName:"Doe"};
// Long
const person = {
firstName: "John",
lastName: "Doe",
age: 50,
eyeColor: "blue"
};
For readability, avoid lines longer than 80 characters. If a JavaScript statement does not fit on one line, the best place to break it, is after an operator or a comma.
document.getElementById("demo").innerHTML =
"Hello Dolly.";
Use simple syntax for loading external scripts (the type attribute is not necessary).
<script src="myscript.js"></script>
Most web servers (Apache, Unix) are case sensitive about file names. Always use lower case file names (if possible).
Coding conventions are not used by computers. Most rules have little impact on the execution of programs.
Indentation and extra spaces are not significant in small scripts.
For code in development, readability should be preferred. Larger production scripts should be minimized.
How you feel about this blog:
Share this blog on:
If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com
Contact UsWe are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..
Copyright ©
, Lynxsia IT Solutions, All rights reserved