+ 1
JavaScript
What characters can be used to start a variable?
7 Answers
+ 7
var
+ 4
@Medhat Youssef! I don't know, but my teachers says var keyword..
many professional engineers who work Microsoft they says use var.
+ 4
@Medhat sir thanks for this type of info.
+ 3
technical user says use variable for only var..
+ 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
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.
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.