« links for 2006-09-08 | Main | links for 2006-09-09 »

The Simplest Example of Recursion in JavaScript

Here is the simplest example of recursion that I can think of:

(function (arr, count) { 
  if(count < (arr.length -1)) {arguments.callee (arr, ++count)}
})(['This','is','trivial!'], 0);

Why is this important?

This example might become important if I were hiring someone to work with me, and I wanted to establish quickly that they had an intermediate skill level in JavaScript. While the example is quite trivial technically, it is quite incomprehensible to the typical "Web" designer.

Of course, I would like to hire someone who is a little of both (designer and engineer), so I would also ask questions like:

  • What are two colors that are complementary?
  • What is an Icon?
  • What is the difference between an icon and some other type of graphic, say a photograph?

Again, I think these questions are trivial for a designer to answer, but much harder for "server-side" programmers.