Earlier quoted context omitted.
typeof 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. Javascri…
Well 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.
Do you really know JavaScript?
61–70 of 73 posts
Re: Do you really know JavaScript?
#62I really wouldn't draw any larger conclusions about Javascript from these examples or from the results of this test. These are edge cases. every language has them No sane programmer would put anything like these examples in a normal program, and knowing these edge cases doesn't really help you solve problems or get things done. Because you just won't encounter them in real life.
var array = ["a", "b"];
var otherArray = ["c", "d"];
otherArray.forEach(array.push, array);
console.log(array);
I expected array to become ["a", "b", "c", "d"], but it actually becomes ["a", "b", "c", 0, , "d", 1, ]. This is because Array#push accepts 1 through n arguments, not just 1 argument.(I couldn't use Array#concat for reasons that don't show up in this simplified example.)
Re: Do you really know JavaScript?
#63I really wouldn't draw any larger conclusions about Javascript from these examples or from the results of this test. These are edge cases. every language has them No sane programmer would put anything like these examples in a normal program, and knowing these edge cases doesn't really help you solve problems or get things done. Because you just won't encounter them in real life.
Yes, but what other common language besides PHP has so many ridiculous edge cases? None I use.
and Python. And Perl of course. Bash.
I bet you could make a similar quiz for Java too.
Re: Do you really know JavaScript?
#64I really wouldn't draw any larger conclusions about Javascript from these examples or from the results of this test. These are edge cases. every language has them No sane programmer would put anything like these examples in a normal program, and knowing these edge cases doesn't really help you solve problems or get things done. Because you just won't encounter them in real life.
To be honest, I spent half an hour today debugging some JavaScript I'd written recently that looked something like this: var array = ["a", "b"]; var otherArray = ["c", "d"]; otherArray.forEach(array.push, array); console.log(array); I expected array to become ["a", "b", "c", "d"], but it actually becomes ["a", "b", "c", 0, , "d", 1, ]. This is because Array#push accepts 1 through n arguments, not just 1 argument. (I…
Your code sample is not surprising or obscure to someone who has skimmed documentation on "push" and "forEach"
Re: Do you really know JavaScript?
#65Earlier quoted context omitted.
I create fully fledged JS apps on a big scale, the difference from this test to reality is startling. The difference is I enforce the use of the closure compiler in our team so 99% of these issues are caught by the compiler. end of story. this test is bullshit.
What benefits do JS apps have over a server-side language such as Java, C# or Ruby? Especially in an enterprise environment. In most of my limited experience JS has been harder to work with than almost anything I have encountered. My personal experience using JS client side apps has left me feeling sour. Every time I visit a webpage and immediately hit a JS loading screen I cringe. Gmail is about the only I dont comp…
Re: Do you really know JavaScript?
#66Re: Do you really know JavaScript?
#67Re: Do you really know JavaScript?
#681 + - + + + - + 1
One plus (negative of ( negative one))? (and the successive pluses don't matter?)
Re: Do you really know JavaScript?
#69Earlier quoted context omitted.
I create fully fledged JS apps on a big scale, the difference from this test to reality is startling. The difference is I enforce the use of the closure compiler in our team so 99% of these issues are caught by the compiler. end of story. this test is bullshit.
What exactly do you mean by "fully fledged JS apps on a big scale"? When it comes to more traditional languages like C, C++ and Java, "fully fledged" and "big scale" are descriptors usually reserved for multi-million line systems consistently worked on by 50+ full-time developers at a time. I'm very suspicious of such terminology being applied to JavaScript applications. We generally see a much, much smaller scale wh…
Re: Do you really know JavaScript?
#70Earlier quoted context omitted.
I create fully fledged JS apps on a big scale, the difference from this test to reality is startling. The difference is I enforce the use of the closure compiler in our team so 99% of these issues are caught by the compiler. end of story. this test is bullshit.
What benefits do JS apps have over a server-side language such as Java, C# or Ruby? Especially in an enterprise environment. In most of my limited experience JS has been harder to work with than almost anything I have encountered. My personal experience using JS client side apps has left me feeling sour. Every time I visit a webpage and immediately hit a JS loading screen I cringe. Gmail is about the only I dont comp…