Are anonymous functions a bad practice in JavaScript?

前端 未结 6 789
别那么骄傲
别那么骄傲 2020-12-30 22:36

I was reading that using anonymous functions in javascript is bad practice, because it can make debugging a pain, but I haven\'t seen this for myself. Are anonymous function

6条回答
  •  温柔的废话
    2020-12-30 23:04

    I would say the contrary, lambdas ( alias ) make some expressions much more succinct. If you're binding multiple event handlers to multiple events it would be tedious giving a function name to each and every event handler, for example.

    It's more helpful and time-conserving than not, even if it makes debugging a little bit harder but I rarely struggle with debugging because a function is anonymous. And you should use JSLint to make your life easier when coding.

提交回复
热议问题