+ 1

Is declaring variables using var in JavaScript preferred over other languages?

In JavaScript you can declare a variable using var. Other languages use int, string, Boolean, etc. Do you find this way an advantage or a disadvantage?

20th Apr 2018, 2:46 PM
Miapolis
Miapolis - avatar
1 Resposta
+ 1
JavaScript is the dynamic programming language like PHP, Python etc. instead of static languages like C, Java so you need to declare types of variables. It is just question of convenience. If you need to use this option learn a TypeScript please. It is language from Microsoft team and it claims to declare with number, string or boolean and it also support classes, constructors and interfaces (just a syntax sugar because these abilities were realized using functions and prototypes)
20th Apr 2018, 3:00 PM
Sergey Vishnevsky
Sergey Vishnevsky - avatar