°Û °Û ÞÜ ±Û °Û °Û ÜÛÛ ÛÜ ±Û ²Û°ÛÛÛÛß°Û ÜÜÜ ±Û ÜÜ ÜÛÛÛÜ°ÛßßßÛ°Û °Û ÛÛ ° ÛÛ±Û ±Û ÛÛ ±ÛÛßßßÛܱÛÛßß°ÛÜÜÜß °Û°ÛÛÛ ÛÛ ° ÛÛ±Û ±Û ÛÛ ±Û °Û±Û °ÛÜ °ÜÛßßÛ°Û °Û ßÛ ÛÛß °ÛÛÛ ßÛÛÜ°ÛßÛÛÛÛß±Û °ÛÛÛß°ÛÜÜÛ²°Û °Û Outbreak Magazine Issue #7 - Article 2 of 16 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' Recursive Function Calls ======================== by Timeless 2002-06-10 One day I was messing around because I was bored and thought I'd try writing some one-liner code in JavaScript. The first thing that came to me to try was a function that calls itself without any hope of breaking out of the sprial. I simply placed the following in the address bar of Internet Explorer to run the code and pressed Enter (some people like to use the "Go" button): javascript:function me(){me()}me(); Naturally, it ran out of stack space and presented me with an error stating the fact. This is perfectly acceptable behaviour. Very well, so I tried a different approach. What if I made the function add characters to the web page (document body) recursively. Naturally I would either expect to see a stack space error or an out of memory error (whichever happens first). So here's my next one-liner: javascript:function w(){document.body.innerHTML+=' ';w()};w(); Well, shock, horror and disbelief... there was no stack nor memory error at all! In fact, the browser just died on me! I had mixed results though and needed to tweak the code a bit because in some cases it would only crash on the second attempt. So I made it look like this (fit on one line please): javascript:function w(){document.body.innerHTML+=' ';w()}; setTimeout('w()',100);w(); This new code would manage to run a second recursive call even after the first one had died (silently!). This time it killed the browser much more consistently. Notice that I am using "innerHTML", that's because "document.write" behaved as it should - it reported an out of memory error. So basically, if the innerHTML property can be overflowed... *insert your imagination here* - Timeless PS. Greetz to all at #hackerzlair and #outbreakzine and to Radioactive_Raindeer and splitfeed, and all my other friends - you know who you are.