+ 2
Why JavaScript is called a loosely typed language?
2 Réponses
+ 2
I'm taking an educated guess here, based on lessons I've learned from this site among others, I think Javascript is called a loosely typed language because it has features which allow for more lenient input, such as automatic type conversion. For instance, in certain languages such as C++, you usually have to explicitly declare the data type you want to use to use when you assign a variable to a value, so for an integer it would be like int varName = 42; or for a string it would be string varName = "bar"; It has the data type preceding the variable name in each statement.
Contrast this with similar variables in Javascript, where regardless of the type of value you are assigning to a variable, it'll be something like var varName = 42 or var varName = "bar", where it doesn't matter what type of value we assign to a variable, Javascript performs a type conversion.
+ 2
Loosely typed languages (javascript, python, perl, etc) are ones that don't require you to declare a variable (with an explicit type) before you use them. It's typically associated with interpreted languages (which are a bit more flexible about their memory usage).
Strongly typed languages (java, c/c++, Fortran) are translated into another form before they can be run, and require a bit more structure in their coding (and are faster to run, as a result).
Does that help?