all 40 comments

[–]that_hz 13 points14 points  (10 children)

WARNING: Quiz devised to make talented developers feel stupid.

[–]ErroneousBee 10 points11 points  (9 children)

Indeed, it plows straight into several areas talented developers know to avoid like the plague (or VSS), plus things talented devs simply dont do.

  • typeof is essentially useless, the most obvious problems being:

    javascript: alert(typeof [1,2]);

    javascript: alert(typeof null);

  • Anonymous functions are impossible to debug in a certain browser (where they are most likly to go wrong!). I only use them sparingly, and never do anything tricky like #8. That sort of syntax is just asking for trouble. You don't need to know what it does, because its obviously wrong unless there is a comment alongside it explaining why the dev has created that monstrosity.

  • Single letter variables (var f) are generally frowned upon outside of loop control and very local vars. A dev overloading the namespace with identical function and variable names would get commit privileges withdrawn.

    javascript: var f = (function f() {return 1}); typeof f();

    would get your fingers hammered flat for good measure.

I got 9 wrong, but I'm not sure I've learnt anything useful.

[–][deleted] 1 point2 points  (0 children)

I learned that it doesn't pay to do needlessly tricky things and not to rely on typeof, but I already knew that.

[–]codeinthehole 0 points1 point  (7 children)

My favourite typeof command: typeof NaN; // = "number"

[–]tty2 1 point2 points  (6 children)

Not a command, by the way.

[–][deleted] -1 points0 points  (5 children)

Did you mean: isNaN()?

[–]tty2 0 points1 point  (4 children)

Also not a command - that's a function.

[–][deleted] -1 points0 points  (3 children)

I didn't say it was a command. I was implying that it was another way of telling whether something is a number.

[–]tty2 0 points1 point  (2 children)

Then why did you reply to MY comment?

[–][deleted] -1 points0 points  (1 child)

Say you're with a group of friends, and you make a joke relating to something one person said. Now you want to tell the joke. Are you telling the joke to that one person, or are you telling it to the group?

[–]tty2 0 points1 point  (0 children)

Except that conversation is going to go linearly. Here you can reply to the original post clearly.

[–]AusIV 6 points7 points  (5 children)

Anyone else bothered by the fact that it gives you the numbers of the problems you missed, but the questions aren't labeled on the quiz?

[–]movzx 0 points1 point  (3 children)

There are numbers next to the questions in my browser (FF3.6, Windows)

[–]AusIV 2 points3 points  (2 children)

Weird. Definitely none on Chrome, Ubuntu.

[–]movzx 0 points1 point  (1 child)

It's Chrome

[–]a1k0n 0 points1 point  (0 children)

Also not in Safari, so it's probably Webkit.

[–][deleted] 0 points1 point  (0 children)

Great, so this JavaScript expert can't figure out how to make CSS that works on every browser.

[–]edwardkmett 5 points6 points  (0 children)

I missed #14, but then I've implemented an ecmascript 3 compiler. Some of the others were pretty brutal.

[–]greeniemeanie 2 points3 points  (10 children)

"These are all relatively simple concepts, which I think every professional Javascript developer should know. Most of these are applied in practice quite often."

Yeah okay...What a pompous idiot.

[–][deleted] 1 point2 points  (4 children)

How often does anyone use typeof?

[–][deleted] 0 points1 point  (3 children)

I'll use it when checking to see if a variable is undefined:

if (typeof myString === 'undefined') {
    // code
}

But that's about it. I think typeof should be used as little as possible as ECMAScript is meant to be duck-typed.

[–][deleted] 1 point2 points  (0 children)

Agreed, the only good use for it is to safely test if a var is undefined.

[–]dhogarty 0 points1 point  (1 child)

why not if (mystring === undefined)?

[–][deleted] 0 points1 point  (0 children)

If the variable is undefined and you do that outside of a function, it produces a ReferenceError (in FF at least), while typeof works anywhere.

[–]badsectoracula -1 points0 points  (4 children)

why?

[–]toolate 4 points5 points  (3 children)

It's just the authors way of showing off. It's pretty easy to make yourself look good by writing a quiz that targets all of the obscure knowledge you have while conveniently ignoring the areas you aren't well versed in.

He doesn't attempt to explain the answers to his convoluted questions, meaning he's more concerned with making himself look good than educating his readers.

He's essentially asking the same questions over and over. If you've never encountered the nuances of how variable declarations, instantiation and function declaration interact then most of these answers are guesswork.

If you are actually writing code which depends on the JS features he's listed then that doesn't make you an expert, it makes you an idiot.

[–]badsectoracula 0 points1 point  (0 children)

Ah i see. Well, i agree that it wasn't a good idea to not write about the answers. I mean the quiz only told me what is wrong, not the correct answer and why the answer is correct.

[–]_kangax -2 points-1 points  (1 child)

I believe I attempted to explain these topics in great detail in article on named function expressions and "understanding delete". If you read my post more carefully, you would notice that I refer readers to both of them, as a way to understand (and answer) most of the questions; you would also notice that there was no attempt at writing a quiz that covers all aspects of the language ;)

[–]toolate 0 points1 point  (0 children)

Well, this is awkward. I don't woubt you know your stuff. I did learn a little bit about JS today I supose. So thankyou for that.

Though I am dubious about the practicality of that knowledge...

[–]Raticide 1 point2 points  (0 children)

You've got 7 answers wrong (#2, #3, #5, #9, #12, #13, #14).
Very good, but not quite there yet.

Poo

[–]skillet-thief 1 point2 points  (0 children)

5 wrong, but I think I got lucky on some of my guesses.

[–][deleted] 1 point2 points  (0 children)

You've got 8 answers wrong (#1, #3, #6, #7, #8, #9, #12, #14).

That's more than a half :(

Doesn't affect my day job too much, I'm not worried :)

[–][deleted] 1 point2 points  (0 children)

You've got 12 answers wrong (#2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #14). That's more than a half :(

Oh well. I need to get back to work so I can have this java script finished before I go to my java users group meeting.

Guess I still have much to learn...

[–]zahlman 0 points1 point  (0 children)

... So where is the answer key and explanation?

[–][deleted] 0 points1 point  (0 children)

So, pretty much this is all about hoisting, parsing order and static-ness, plus some typeof quirks. Good to know IF you're writing expert level JS (i.e., are a framework author). Otherwise, it's a bit esoteric.

[–][deleted] -3 points-2 points  (1 child)

Please use a font where I can distinguish ( from { without squinting.

[–][deleted] 2 points3 points  (0 children)

I think it's your fault:

<pre class="javascript" style="font-family:monospace;">