On Jul 31, 4:43 pm, "Richard Cornford" <Rich...@litotes.demon.co.uk>
wrote:
[snip]
> But then I am very cynical.
At least you know!
> I have the problem of setting javascript technical tests for interviews
> (not that often, but it is part of my job), so form time to time I think
> about what questions they should include, and what I would be looking
> for in an answer.
Given your apparent high standards and opinion of the general quality
of JavaScript programmers, how do these employee searches go for you?
Do you simply take the best applicant or do you wait for a
satisfactory applicant?
> For example, as a verbal question I would tend to ask;
> "which side of an inequality expression is evaluated first?" Not because
> I want to be told the answer (I would not memorise that sort of detail
> (after all, it does not matter 99.9% of the time), and it would scare me
> to encounter someone who did), but because I would want to hear "I would
> have to look it up" (or words to that effect), so I could ask where they
> would look it up, and if given the correct answer hand them a copy of
> the document to see if they were familiar enough with it (and
> interpreting it) to give me the correct answer quickly.
If I was feeling bold and relatively happy with my current job, I
would answer that my code should not depend on knowledge of which side
is evaluated first. That is information that likely anyone would have
to look up and results in code that is not quickly read or easily
maintained.
> On the other hand there are things I would expect someone to know
> (without having to look it up), and one of those is Identifier
> resolution against the scope chain.
>
> "Inspired" by one of the more ambiguous questions on your meebo.com page
> I thought the following might make quite interesting written test
> questions, and give an impression of my thought process in setting
> javascript questions:-
>
> /* unknown global code */
> function outerFunction(){
> /* unknown outer function body code */
> function innerFunction(){
> /* unknown inner function body code */
> with(anObjectReference){
> x = 5; //<--- The subject line of code.
> }
> /* more unknown inner function body code */
> }
> /* more unknown outer function body code */}
>
> /* more unknown global code */
>
> /* ************************************************** ******\
> | Note: Three facts about the 'unknown' code:- |
> | |
> | 1. There are no more function definitions, no function |
> | expressions and no uses of the Function constructor. |
> | 2. There are no - with - statements in the unknown code.|
> | 3. There are no uses of the - eval - function. |
> \************************************************* ******* */
David Mark posted nice answers. I really enjoyed this as an exercise.
I too have never used "with".
I agree with David's sentiment about using "with" as a weeding
technique during the interview process. I think good JavaScript
programmers likely don't use the "with" statement because it is hard
to maintain, prone to creating properties in the wrong place and
cannot be optimized (well?) by the compiler. These warnings about
"with" are plastered all over the place and a good JavaScript
programmer my have never bothered to use "with" before. The places
where I have encountered "with" have been in code that otherwise had
horrendously bad JavaScript and was written by programmers for whom
I've come to have low respect for many reasons.
If you ever feel like posting other interesting exercises please do!
Thanks,
Peter