Using arguments.callee to reference a function itself.

from jquery ninja book

by dandoyon

HTML

<ul id="results"></ul>

CSS

#results li.pass { color: green; }
#results li.fail { color: red; }

JavaScript

function assert(value, desc) {
    var li = document.createElement("li");
    li.className = value ? "pass" : "fail";
    li.appendChild(document.createTextNode(desc));
    document.getElementById("results").appendChild(li);
}

var ninja = {
    yell: function(n) {
        return n > 0 ? arguments.callee(n - 1) + "a" : "hiy"; //#1
    }
};
assert(ninja.yell(4) == "hiyaaaa", "arguments.callee is the function itself.");