variables in js

Solutions on MaxInterview for variables in js by the best coders in the world

showing results for - "variables in js"
Gustave
26 Aug 2018
1//choose the best for your solution
2var myVariable = 22; //this can be a string or number. var is globally defined
3
4let myVariable = 22; //this can be a string or number. let is block scoped
5
6const myVariable = 22; //this can be a string or number. const is block scoped and can't be reassigned
Melvyn
22 Mar 2016
1var Hello = "World";
2let bool = false;
3const int = 8788;
Marta
30 Sep 2017
1	Variables can have anything, you define them as equal to something
2    
3    eg:   var x = 22
4    var statement = 'hello!'
5    var isAbool = true 
6    
7    there are three types of variables:
81. var 
92. let
103. const 
11
12var is a normal variable
13let is a variable whose value can be changed eg: let h = 12, h = 10(we changed the value, if you run this, there will be no error)
14const is a variable whose value cannot be changed, if you change the value of a const, you will have errors in you code