0

Can anyone tell when to use keyword var and keyword let?

18th Jul 2016, 3:19 PM
vijaya narasimha
vijaya narasimha - avatar
8 Respuestas
+ 4
You should use "let" when you sure that containing value wouldn't change. It is a constant (like number Pi or else). "let" help us use system memory better
21st Jul 2016, 6:53 AM
Егор Патрикеев
+ 2
var is a variable , which changes but let is a constant , which doesn't change
8th Jan 2017, 4:20 PM
SUMANTH VENKATA SAI KRISHNA Manduru
SUMANTH VENKATA SAI KRISHNA Manduru - avatar
+ 1
var declares a variable whose contents can be changed whereas let declares a constant that connot be changed (i.e. let myFirstName = Scott vs var myFavoriteColorToday = Blue). Its unlikely that I'll change my first name but it's quite possible that I might choose a new favorite color.
19th Jul 2016, 1:20 AM
Scott Hinkle
+ 1
let will be used when you are sure there is no change in value like universal truth or mathematical equations for example π=3.14, it will never change. var will be used for normal variables
24th Jul 2016, 12:25 PM
Ravi Rupareliya
Ravi Rupareliya - avatar
+ 1
simply, (let) is used when you define a constant wich eventually will hold a fixed value. and var is used when you define a variable that will change its value
9th Aug 2016, 9:43 PM
jamal
jamal - avatar
0
Basically, things like someone's age is "var", someone's gender is a "let"
19th Jul 2016, 1:36 PM
ccavute
0
let π = 3.14 // It is a constant and we should use let keyword to avoid changing it by accident or sonething like that.
6th Aug 2016, 8:02 AM
Abdelkader Ait Assou
Abdelkader Ait Assou - avatar
0
If you use let, the value can't be changed If you use var, it can
8th Oct 2016, 10:50 AM
Tojo
Tojo - avatar