3 ms·
I was recently asked given a variable amount of parameters passed into a JavaScript function how would you sum all of the parameters. My answer was I would not
by kls 15y ago
I was recently asked given a variable amount of parameters passed into a JavaScript function how would you sum all of the parameters. My answer was I would not write JavaScript code like that, and would fire anyone on my team that did. Needless to say I did not get the job, nor did I want it. I have been critical of this type of interviewing for a long time. Trick questions and magic code really provide little insight to the value of a candidate. Further most interviewers do not have the clinical background to even interpret the results as many of these questions are based off of psychological tests. It's a cargo cult mentality and reflects poorly on an organization.
- goo 15y agoI think this is a reasonable question, insofar as the interviewer probably just wanted to hear that you knew how the "arguments" object works. The base2 library, for example, uses arguments in its format function: http://www.google.com/codesearch#O7TxUbFbPP4/lib/src/base2.js&q=format%20package:http://base2%5C.googlecode%5C.com&l=1542 http://www.google.com/codesearch#O7TxUbFbPP4/lib/src/base2.j... Quizzing people on language features seems a tiny bit silly, but I respect it as a method of ensuring expertise in a given language. edit- I actually don't think it ensures expertise, but it can be a signal of a lack of expertise, so it is a useful method to avoid a false positive on a hire.
- kls 15y agoI have to respectfully disagree, I have built a lot of JavaScript based application, some of them huge code bases for the like of IBM and not once have I had to resort to using the arguments object. I consider myself to be an expert, but should I ever need to use it, I would look up the API because it is not a feature used in the mainstream of development. Understanding technical nuances of a languadge does not make a developer an expert, delivering a clean, maintainable and elegant code base to production to generate revenue does. Now my opinion would differ if it was someone hired to actually work on V8 or one of the JavaScript run-times but requiring mastery of nuances of a languadge when they will be used rarely if at all seems to me to be a filter that can eliminate good candidates in favor of trivia knowledge. Trivia can be looked up, delivery and maintainability cannot, these questions favor trivia over delivery.