Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> more informative logging.

> var foo = function realName(){};

Nice trick, thanks! The "anonymous" function is especially annoying when profiling code, so that should address that annoyance. I often struggle with picking names, but another post here shows that "foo" can just be reused as the function name.



> I often struggle with picking names, but another post here shows that "foo" can just be reused as the function name.

I'd be very careful about giving them the same name if you're working with IE at all. IE8 and below's JScript does some really strange stuff with function expressions, leaking and hoisting them all over the place. [1]

Instead, I'd just append a character or something to differentiate the two. I've been using the format advocated for in Javascript Patterns[2][3]:

    var foo = function fooF(){};
[1] http://kangax.github.io/nfe/#jscript-bugs

[2] http://shichuan.github.io/javascript-patterns/

[3] https://github.com/shichuan/javascript-patterns/blob/master/...


Thanks for the tip, adopted. The kind of tip that might have saved me a lot of time in the future.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: