4 ms·
I wouldn't say that. The really nasty bugs come exactly from examples like these. This can save you hours at some point, I had to find some of them the hard wa
by sek 13y ago
I wouldn't say that.
The really nasty bugs come exactly from examples like these. This can save you hours at some point, I had to find some of them the hard way.
- TheZenPsycho 13y agotypeof is broken. instanceOf is broken. precision arithmetic on floats is broken var hoisting and function scope is a misfeature It's more useful to know those facts than to know the exact result of them in individual contexts well enough to answer a multiple choice question. It's more useful, if you see these examples in real life, to just rewrite them from scratch to not use the broken parts of javascript. Javascript has pitfalls and ugly parts. they can be avoided. this test gives you no great insight into them, or how to avoid them.
- rnnr 13y agoYeap but the most probable way to learn about them is to lose several hours debugging each of them. I don't think there is other language that comes close to javascript. Ok it's everywhere now, you make a lot of money with it, that's what we have now, but you and others defending it make my ears bleed.
- sek 13y agoWell even if something is "broken" you have to use it once in a while, how can you avoid function scope and typeof? Also sometimes you have to maintain code, so it's not a choice. There are always explanations that are helpful. You have to know about the pitfalls to be able to avoid them. The questions just make you study the examples and also it's more fun this way.
- TheZenPsycho 13y agoI actually totally agree with you. But if this is your only exposure to these things then I can't expect you'd gain that much insight.
- hk__2 13y agohow is function scope a misfeature?
- TheZenPsycho 13y agoit should have been block scope.
- al2o3cr 13y ago"typeof is broken. instanceOf is broken. precision arithmetic on floats is broken var hoisting and function scope is a misfeature" Sounds like one hell of a PR pitch. :) I got 15/37, in no small part by guessing "what's the most bizarre and inconsistent thing that could happen here"? Apparently my imagination is less vivid than JS's.
- TheZenPsycho 13y agoI'm not saying Javascript is perfect. just that you can't draw many useful conclusions from a document that sets out to find specifically its weirdest (mis)features. And actually you could avoid using "typeof" by using polyfills/builtins for the new "is[Type]" range of functions in ecmascript5. or a similar one from a library.