Here I'll post some small functions. Hopefully a few will give you a smile :)
myFun=function(){
var me=arguments.callee;
me.browser= (document.all)
? function(){alert("Hi I'm IE")} : function(){alert("Hi I'm FireFox")};
myFun=function(myFun){
arguments.callee.caller.browser();
alert(myFun);
}
myFun(myFun);
}();
This function at first glance exhibits some strange behaviour. Not the fact that it tests for document.all ;), but the result of alert(myFun). I thought it would have been == arguments.callee.caller, like this:
myFun=function(){
var me=arguments.callee;
me.browser= (document.all)
? function(){alert("Hi I'm IE")} : function(){alert("Hi I'm FireFox")};
myFun=function(myFun){
me.browser();
alert(arguments.callee.caller+"\n~~~~~~~~~~\n"+myFun);
}
myFun(me);
}();
alert(myFun);Result of alert(myFun): undefined... and
myFun=function(){
var me=arguments.callee;
me.browser= (document.all)
? function(){alert("Hi I'm IE")} : function(){alert("Hi I'm FireFox")};
myFun=function(){
me.browser();
alert(arguments.callee.caller+"\n~~~~~~~~~~\n"+myFun);
}
myFun(me);
}();
alert(myFun);
Result of alert(myFun): undefined... and here is an anonymous function:
new function(){
arguments[0].message();
}({message:function(){alert('called by null')}});