+ 1

JavaScript

What characters can be used to start a variable?

14th Aug 2017, 3:01 PM
MD.Maraj Hossain Siddiki
MD.Maraj Hossain Siddiki - avatar
7 Answers
+ 7
var
14th Aug 2017, 3:10 PM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 4
@Medhat Youssef! I don't know, but my teachers says var keyword.. many professional engineers who work Microsoft they says use var.
14th Aug 2017, 7:33 PM
meherDev
meherDev - avatar
+ 4
@Medhat sir thanks for this type of info.
14th Aug 2017, 7:39 PM
meherDev
meherDev - avatar
+ 3
technical user says use variable for only var..
14th Aug 2017, 7:26 PM
meherDev
meherDev - avatar
+ 1
what i am saying is .. every keyword has a good use in different occassions .. sometimes using var will be more effective than let .. and vice versa. so there is no right or wrong answer here.. because it all depends on usage .. although sometimes you might face some problems with var when using it in "for" loops .. this does not happen in the case of "let" though.. and i must declare that i don't endorse one over the other
14th Aug 2017, 7:36 PM
Medhat Youssef
Medhat Youssef - avatar
0
in javascript you can use 3 keywords to declare a variable .. each of them has a different purpose: 1- var: the var keyword is the most commonly used. It dedfines a variable and it follows the environment which it is used in .. for example, a variable declared by var and was declared inside a function can not be used outside of that function. 2- let: the let keyword is new to javascript and it is very nice to use if you want to give more "privacy" to your variables. Meaning every variable declared by let will be accessible only to its code block. 3- const: the const keyword is very handy if you want to declare a constant, which is a value that you don't want to change later.
14th Aug 2017, 3:36 PM
Medhat Youssef
Medhat Youssef - avatar
0
@meher .. people who work at Mozilla are requested to use the "let" keyword all the time .. so it's a matter of what you do and which coding environment you deal with.
14th Aug 2017, 7:30 PM
Medhat Youssef
Medhat Youssef - avatar