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

> 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.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: