To know what is variable in programming please read this.
var name = 'cityofbinary';
How to declare variables in JavaScript?
JavaScript has very simple syntax to declare variables. It will even allow you to use a variable even without declaring it. But in JavaScript script mode it requires you to declare the variable before using it.
varname = 'any value'
Variables size in JavaScript
JavaScript doesn't allow you to mention the size of a variable. By default it will reserve 64 bytes of space in RAM. For every variable it is common. You can't change this.
How to specify datatype in JavaScript variable?
JavaScript will change the variable's type to what type of data you are assigning to that variable.
first = 'string'; // string type first = 1; // int type first = 1.5; // float type first = true; // boolean type
You can assign the string data to the variable. To the same variable you can assign int type data or any other JavaScript supported datatype.Variable types
JavaScript has three types of variables
- let variables has block scope and it is mutable.
- var variables has global scope and it is mutable.
- const variables has block scope and it is unmutable.