3 ms·
JS is leaky. It's Type Coercion often relies on the inner string representation of its objects. So many of its oddities come from this. JS doesn't have integer
by shakna 10y ago
JS is leaky. It's Type Coercion often relies on the inner string representation of its objects. So many of its oddities come from this.
JS doesn't have integers. It only has floating point numbers, and the complexity they can bring.
> 10.8 / 100 => 0.10800000000000001
Its inconsistency on dealing with things that become NaN confuse the hell out of a good deal of people, because it simply doesn't reflect the way other languages deal with it.
> Array(2).join("wat" - 1) => NaNNaN
> Array(2).join("wat" + 1) => wat1wat1
JS is "wacky" because a programmer often has to understand implementation details to debug.
A C programmer in rare cases may need to understand how their code translates to assembly, yes. But it is incredibly rare.
A Python programmer almost never needs to understand how the object type is constructed, or how instanceof works.
A Ruby programmer can get by without understanding how their numbers change from integers to BigNums and back.
A Scheme programmer doesn't need to understand Cheney on the MTA or how their compiler generates C code. It explains speed and other tradeoffs, but it rarely if ever changes the actual code they write.
In JS, I have to be careful not to use arrays and currying together, because I might get a false where I expected an array.
This isn't a language I would want to hand to someone who has never programmed.