In javascript, variables have meaningful names, these names are called identifiers. Identifiers are unique, it means once a variable name is declared or used, it cannot be used for other variable.
Javascript Identifiers naming rules
- Javascript supports Unicode characters, Hence other language words or characters can be used as variable names.
- Identifier must start with a letter or underscore or dollar symbol and then digit can be used, No other operator or symbol is allowed.
- Identifier must not start with a number.
- There should not be space between letters, digit or words.
- Javascript is a case-sensitive language, so a and A are not same.
- Variable names should not contain reserved keywords.
Valid Identifiers example
Below are the few valid javascript identifier name examples.
<script>
$age = 30;
_name = 'yourshala';
$_country = 'India';
language = 'Hindi';
programming_language = 'javascript';
airQuality = 'Good';
isRaining = true;
isAge30 = false;
</script>
Invalid Identifiers example
<script>
0name = 'yourshala'; // Error
programming language = 'javascript'; // Error
</script>