Strong versus Loose Typing in JavaScript

Being a long time JavaScript developer, I’m perfectly happy with the fact that JavaScript is loosely typed. I think the reason strong typing in JavaScript is gaining in popularity is because more and more developers are using JavaScript that are used to programming in strongly typed languages. So there’s no reason for me to use something like Typescript that adds static typing to the language. Anyway, I came across this quote from Douglas Crockford in his book, JavaScript: The Good Parts, which explains my feelings on the subject better than I can.

The fashion in most programming languages today demands strong typing. The theory is that strong typing allows a compiler to detect a large class of errors at compile time. The sooner we can detect and repair errors, the less they cost us. JavaScript is a loosely typed language, so JavaScript compilers are unable to detect type errors. This can be alarming to people who are coming to JavaScript from strongly typed languages. But it turns out that strong typing does not eliminate the need for careful testing. And I have found in my work that the sorts of errors that strong type checking finds are not the errors I worry about. On the other hand, I find loose typing to be liberating. I don’t need to form complex class hierarchies. And I never have to cast or wrestle with the type system to get the behavior that I want.