1

I have a background in Java, and already know that these two languages are unrelated. But from a programming perspective, it seems like specifying var types (like in Java) makes code more secure/ less prone to bugs. Why doesn't Javascript require this, when a var can be wildly anything from a number to a complicated function?

devwraps
  • 37
  • 4
  • 4
    Because it's dynamically typed. If you think static typing is better, *use statically typed languages*. – jonrsharpe May 27 '16 at 17:54
  • There is a language called `TypeScript` which is pretty much a superset of JavaScript that offers strong typing, interfaces and other goodness. There is an optional typing system called `Flow` which is available through an ES6 transpiler called Babel. – Jeremy J Starcher May 27 '16 at 17:58
  • The question is essentially *"What are the benefits of having a dynamically typed language?"*. I would say that [this](http://stackoverflow.com/questions/1517582/what-is-the-difference-between-statically-typed-and-dynamically-typed-languages) is related if not an exact duplicate. – RaminS May 27 '16 at 18:01

0 Answers0