|
|
|
|
|
by jondubois
3059 days ago
|
|
I agree, that makes sense for C/C++ because working with pointers and dynamic memory is a lot more complicated - Types make sense for C/C++ because the focus is execution speed and flexibility (not development productivity). The case you describe very rarely happens to me with JavaScript; having fewer primitives to work with greatly reduces these kinds of issues... Sure it opens up the possibility that you'll do something stupid like trying to add an object with a string; but that's a pretty silly thing to do. If you name your variables properly then that never happens. With C/C++, there are many primitives so you might get errors when you try to assign an int64 to an int8 (for example)... With JS, however, because there are fewer primitives so the odds of that happening are much much smaller. Because there are so few primitives in JS, it's easy to remember how they all interact with each other. The only exception is the boolean truth table for '==' (which is a mess); that's why it's usually recommended to use '===' instead. |
|