Conversation
|
i sorry 2014/1/6 gyfnice notifications@github.com
|
|
This is good because the JS debugger will show the name of the function in the stacktrace if you follow the good style. Otherwise, it's just an anonymous function, which is harder to debug. |
|
How I get information about the stacktrace?? can you give me a example?Comparison them with image,let me understand them distinction by image,very thanks |
|
Here's a contrived example. Add an event handler to the Anonymous function:Named function:Browsers are getting smarter though. Chrome will show the name of the assigned anonymous function expressions: Named Function:Anonymous function expressionNamed Function expressionHope that helps! 🍻 |
|
thanks @hshoff But as you said,Browsers are getting smarter though.why should we make an unnecessary things that To add the name of the function expression. I still felt unnecessary |
|
This is one of those things that we've found helpful for us. It might not be necessary for everyone. Feel free to fork the style guide and update it to match the style of you and your team. |





Name your functions. This is helpful for stack traces. //I don't understand why this can stack traces??
// bad I think this is good,because very convenience.
var log = function(msg) {
console.log(msg);
};
// good I can't understand why is good? I think is not necessary js style.I hope you can explain this problem for me, I really confused. thank you.
var log = function log(msg) {
console.log(msg);
};