A JavaScript naming conventions introduction by example -- which gives you the common sense when it comes to naming variables, functions, classes or components in JavaScript. No one is enforcing these naming convention rules, however, they are widely accepted as a standard in the JS community. Show
JavaScript Naming Conventions: VariablesJavaScript variables are case sensitive. Therefore, JavaScript variables with lowercase and uppercase characters are different:
JavaScript Naming Conventions: BooleanA prefix like is, are, or has helps every JavaScript developer to distinguish a boolean from another variable by just looking at it:
JavaScript Naming Conventions: UnderscoreSo what about the underscore and dash in JavaScript variable namings? Since camelCase and PascalCase are primarily considered in JS, you have seen that the underscore is only rarely used for private variables or constants. Occasionally you will find underscores when getting information from third-parties like databases or APIs. Another scenario where you might see an underscore are unused function parameters, but don't worry about these yet if you haven't seen them out there ;-) JavaScript Naming Conventions: DashA dash in a JavaScript variable isn't common sense as well. It just makes things more difficult; like using them in an object: 2 |