Are anonymous functions a bad practice in JavaScript?

前端 未结 6 842
别那么骄傲
别那么骄傲 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:50

    Just because everybody uses them doesn't make them good practice (everybody remember using the table element for layout?). But, they're great because they can help clarify and simplify your code, giving less opportunity for something to go wrong.

    But, anonymous functions shouldn't be so complicated that debugging becomes difficult with them. In that case, perhaps it's better to make a new function.

提交回复
热议问题