So you want to write JavaScript for a living?
nczonline.net
nczonline.net
This is especially true if you use node.js to write server-side JavaScript or use jQuery to hide some complexity or if you are making things with HTML5 Canvas, where your DOM interactions are often limited to that single object (or perhaps multiple Canvases). Some of the most impressive things I've seen in the last year were JavaScript sites that had nothing to do with even the slightest shred of DOM manipulation.
Of course I'm not saying that one shouldn't need or want to understand the DOM. It's just interesting to me how things have subtly changed, and as someone who loves and spends a large amount of time with Canvas, to see all these beautiful new things on the web with no DOM-aches needed.
(After all I agree 100% with Resig: JavaScript isn't broken, its the DOM that tends to foul things up.)
$('<div></div>').appendTo(document.body).dialog(dialogOptions);
Also when you are writing custom widgets you gotta understand the DOM, not even jQuery can hide everything away.Note: Still a WIP.
- Can you write out AJAX code that reliably works in all versions of IE by memory? And don't forget to add automatic jsonp support for cross-domain requests.
- Do you remember how to get the width and outerWidth of an element in a reliable cross-browser way?
There was a time when I could do these things from memory. That time was when I was interviewing for jobs. In daily work, I only have to half-remember these things and can operate at a higher level of abstraction.
Sure, if you just want to add the current date to <div id="rightNow"> then use basic browser builtins, but it's usually more like "I need every other child of each list with the class 'rowStripe' unless it's the last entry in the list", in which case jquery saves you a ton of time.
I also like the community. There seems to be a jquery plugin for damn near everything. Kind of like PHP. Yes it can be a mess. But when you are just trying to "get shit done" JQuery isn't bad at all.
I'd rather let the library developers abstract all that out for me.
It depends. For your average front-end developer adding light functionality to a web page/app? No, probably not.
However, if you are creating heavy, full-featured, client-side web-apps...absolutely.
Not because you need to do it without jQuery, but because you need to understand what jQuery is doing behind the scenes. At least a couple times a year some major website like (to pick at random) Twitter crawls to a halt, bugs out, etc...because some front-end dev treated jQuery like magic without considering what is going on behind the scenes.
So I would say if you serious about being a front-end developer, then sure...spend some time browsing the jQuery source and learn to do things in "vanilla" JS.
In terms of whether to consider it re; hiring, it depends on what you are hiring for.
Perhaps not even 95% of the time.
However, someday, there will be a bug withing jQuery, or a misunderstanding of what it is doing internally, and you will have to debug. You will have to have understanding of the DOM itself.
Meanwhile others do some stuff: like attaching event handlers, manipulating attributes, class names; doing animation, making AJAX requests, etc. Most of these differ to some degree accross browsers and that's there jQuery comes in: to unify the API.
Why, because you can't reach the Mozilla docs? Reference based questions are no way to do an interview. It's easy to look this stuff up.
That's like saying "Heart surgeons don't need to be able to draw a rough diagram of a heart when asked...they can always consult a medical textbook".
Sure...I agree with you that heart surgeons don't need to have every obscure cardiovascular disease memorized...but they need to have memorized the basic cardiovascular functions, how the heart works, what it looks like, etc. The same is true for programmers of any type...there is a base amount of information that you should just know in order to be considered proficient for a particular field.
If a candidate comes in and doesn't know this stuff, that doesn't necessarily mean you shouldn't hire them...however it does mean they are not proficient in whatever field and will need to be trained to some extent.
Also of course, as with any other sort of question; it could be they just had a "brain fart" or off day...but not asking these sorts of questions doesn't make that issue go away.
If they weren't embedded in your memory, you were probably lying about how much Javascript you had written or were really bad at it.
1) What implications do those have on DOM performance?
2) Contrast appendChild when called on a DOM element, vs. an absolutely positioned DOM element, vs. a document fragment
3) Why do you want to avoid calling appendChild w/in a loop?
Keyword I'm looking for from candidates: Reflow, which requires a deeper level of understanding, and that's the level I'm really targeting in an interview.
JQuery walked on in and 'shook up' the world of JS - but now there are so many strong libraries (& micro-libraries) that its more of a matter of filtering out the junk
A few more: What are dangers of using prototype inheritance with many instances of that class (meaning accidentally attaching variables to the prototype rather than the instance)?
What are some gotchas with IE < 9 event objects in event handlers that contain closures?
Explain the same origin policy, why it's important, and how it impacts your development.
(jQuery twister): explain where the '$' variable is defined when used with jQuery. How might you manipulate the DOM in another popup window you've created?
If you're a solo developer writing small applications, this might not be a problem. If you're growing an application and a business this is a very serious concern. As you grow, you need to bring in more developers, but with a cowboy codebase it will be harder and harder to keep everyone productive. Instead of writing new features, they'll spend more and more time just trying to undersand the code, and to fix the inevitable bugs.
Quick fixes are a fact of life though, but use them only until a solid patch can be crafted.