How good it is to use anonymous function in metro style HTML5/Javascript app ? RRS feed

  • Question

  • you people might be knowing  that we loose stack trace when using  anonymous function.. Still is it good practice to use anonymous function building metro style  app ?

    -  plenty of anonymous functions are there i.e. pass as a function argument,self executing anonymous function.....

    • Edited by Web-Farmer Saturday, July 7, 2012 6:16 PM
    Saturday, July 7, 2012 6:15 PM


  • It's mostly a matter of what your preference is.  As you state, you will lose call stack information in any exceptions/error reports and while working in the debugger if you use anonymous functions for everything.  However, sometimes they also make a lot of sense.  The guideline I use my apps is basically if the unit of work being done by a particular function is useful enough in an error report/exception stack trace.  If the parent (the call right before the anonymous function) is enough to tell me what I need to know, I won't name it.  If it isn't enough (e.g. for success/progress/error handlers in promises) I will name it so I know exactly which one was called when looking at a call stack.
    Sunday, July 8, 2012 5:27 AM