4 ms·
Why would that be surprising? NaN as a result definitely means that you cannot multiply array by object in JS either. JavaScript uses IEEE 754 special values, n
by oliverkyss 10y ago
Why would that be surprising? NaN as a result definitely means that you cannot multiply array by object in JS either.
JavaScript uses IEEE 754 special values, not exceptions on arithmetic errors (eg 1/0 returns Infinity instead of throwing). If you bother to learn the language, it doesn't surprise you.
- happyslobro 10y agoThe problems start when you notice that your untyped key-value store has a bunch of NaNs where you were expecting a number. At this point, all you can do is pray that those numbers weren't very important, in the grand scheme of things.
- oliverkyss 10y agoSo when you do calculations with important numbers, you just push the results to the store without checking them and hope for the best? NaNs can happen in any language with floats, it's just that some languages also use exceptions in some situations.
- codedokode 10y agoYou can check the result of every operation manually but it saves you time when the language does it.