Declare JavaScript Variables
- In computer science, data is anything that is meaningful to the computer. JavaScript provides eight different data types which are :
undefinednullbooleanstringsymbolbigintnumberobject
- Variables allow computers to store and manipulate data .
- Variables are making the code dynamic .
- Variable names can be made up of numbers, letters, and
$or_, but may not contain spaces or start with a number.
for examples :
var my_data;
var &member10;
var _mylist;
But var 15num; // it's wrong because variable name should not start with number .
also var my Name; // it's wrong because variable name should not contain any space .
" if we declare a Variable without assigning it any value , so by default it's value is undefined. "
var x; // declaration statement .
x = 5; // assign a value (store value inside the variable) .
An assignment operator (=) which is the operator used to assign a new value to a variable .
Variables are Case Sensitive :
- In JavaScript all variables and function names are case sensitive. This means that capitalization matters.
MYVARis not the same asMyVarnormyvar. It is possible to have multiple distinct variables with the same name but different casing. It is strongly recommended that for the sake of clarity, you do not use this language feature.
Best Practice:
- Write variable names in JavaScript in camelCase. In camelCase, multi-word variable names have the first word in lowercase and the first letter of each subsequent word is capitalized.

Comments
Post a Comment