[removed] inline functions vs predefined functions

前端 未结 13 1884
心在旅途
心在旅途 2020-12-02 11:00

Can any body throw me some arguments for using inline functions against passing predefined function name to some handler.

I.e. which is better:

13条回答
  •  攒了一身酷
    2020-12-02 11:49

    I prefer to use named functions. Named functions show by name on all debuggers (air, firebug, IE).

    Example:

    Notice that you can also have inline named functions like

    {
        method: function obj_method(){}
    }
    

    This way, when you look at the stack trace, you'll see function obj_method instead of anonymous.

    Were you asking about when to inline a function rather than declare it? When it makes sense in the code. If you need it from two different places, it can't be inline. Sometimes inline make the code easier to read, sometimes harder.

提交回复
热议问题