Are anonymous functions a bad practice in JavaScript?

前端 未结 6 790
别那么骄傲
别那么骄傲 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 22:56

    Nope, anonymous functions are used all over the place in JavaScript across the web. It may make debugging a little more difficult in spots, but not nearly enough to say that they shouldn't be used.

    For example, JQuery makes extensive use of them.

    There are a lot of times when you want to use them over formally declared functions, such as when you want to limit their scope.

提交回复
热议问题