4 ms·
> 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 th
by XaspR8d 12y ago
> 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 http://kangax.github.io/nfe/#jscript-bugs
[2] http://shichuan.github.io/javascript-patterns/ http://shichuan.github.io/javascript-patterns/
[3] https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/function-declarations.html https://github.com/shichuan/javascript-patterns/blob/master/...
- gorhill 12y agoThanks for the tip, adopted. The kind of tip that might have saved me a lot of time in the future.