Live data from Hacker News

Do you really know JavaScript?

javascript-puzzlers.herokuapp.com

11–20 of 73 posts

Re: Do you really know JavaScript?

#11

This is a good way to distinguish between someone who knows JavaScript the language from someone who can apply JavaScript to perform DOM manipulation and data requests. Not that there's anything inherently wrong with the latter. I fall firmly in that latter camp; I do all my algorithmic work and heavy lifting in C# and just use JS to get data onto the client and display it. But it's easy for someone like to me to sta…

This isn't really true.

There are some programmers who are walking encyclopaedias of language features. It is absolutely no guarantee that they are good coders. Some simply can't code at all, they know all the motions but cannot see how to thread them together past the simplest of programs. Others cannot distinguish between useful language features and terrible ones, using them indiscriminately and making a terrible incomprehensible mess. And of course some are simply the best programmers you will ever meet.

Javascript is a language full of terrible design decisions. Knowing them all doesn't make you a good coder, in fact simply being taught only the safe parts will often make a better coder than knowing a lot of the results of these parlour tricks.

Re: Do you really know JavaScript?

#12

This is a good way to distinguish between someone who knows JavaScript the language from someone who can apply JavaScript to perform DOM manipulation and data requests. Not that there's anything inherently wrong with the latter. I fall firmly in that latter camp; I do all my algorithmic work and heavy lifting in C# and just use JS to get data onto the client and display it. But it's easy for someone like to me to sta…

Agreed, I use Java for my heavy lifting. Use JS to display the data, provide some client side validation on forms, switch some classes around or manipulate something in the DOM using JQuery or the like.

I cant create a full fledged client side JS app but I dont really need to if I have a larger language helping on the server side.

Re: Do you really know JavaScript?

#13
post #7

I wish there was a 'JavaScript Under the Microscope' like 'Ruby Under the Microscope' by Pat Shaughnessy. I think I would have a much better understanding of JavaScript if I knew how a good javascript engine works.

> I think I would have a much better understanding of JavaScript if I knew how a good javascript engine works.

So would the people who write the good javascript engines.

I'm joking but only partially as they have to write an engine against both a standard and a convention plus support all the hacks going back years.

It's a mess but what I'm slowly and painfully learning is that if you avoid the shoals and hidden wrecks you can do some cool stuff with JS.

Re: Do you really know JavaScript?

#14
I 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.

Re: Do you really know JavaScript?

#16

I 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.

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.

Re: Do you really know JavaScript?

#19
post #7

I wish there was a 'JavaScript Under the Microscope' like 'Ruby Under the Microscope' by Pat Shaughnessy. I think I would have a much better understanding of JavaScript if I knew how a good javascript engine works.

The author of this quiz could have made this a great learning opportunity by linking to the appropriate sections in ECMA-262[0].

For example, question 15 makes a lot more sense when you read "ToBoolean" (Sec 9.2) which shows that all objects (including arrays) are always considered truthy values, however when compared with ==, "The Abstract Equality Comparison Algorithm" (11.9.3) is used, which gives this behavior:

  >> [0] == [0]
  false
  >> a = [0]; a == a
  true
because a shallow comparison is used.

[0] http://www.ecma-international.org/publications/files/ECMA-ST...

Re: Do you really know JavaScript?

#20
post #16

I 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.

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.

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.

Javascript has pitfalls and ugly parts. they can be avoided. this test gives you no great insight into them, or how to avoid them.

Post reply on HN