Wednesday, 29 May 2013

Named functions in Javascript

I am at Progessive.Net at the moment in the Helen Emerson talk. She mentioned a benefit of naming functions, you can then use them to recurse. Normally I would assign a function like
var boo = function() { //something };
But if you name the function as well, you can then use it to recurse. I didn't realise you could do this so I am quite pleased. She also mentioned that it can also help when debugging and when you are catching exceptions.

Anyway, here's an example!

Update: Her examples and presentation is available on her github account https://github.com/helephant/JavascriptObjects I really like the console library that she is using. Quite a cool little thing.

No comments:

Comments System

Disqus Shortname