Using Named Immediately-Invoked Function [removed]IIFE) instead of comments

后端 未结 2 1754
轻奢々
轻奢々 2021-01-02 05:24

What are the pros and cons of utilizing Named IIFEs within JS code to describe and group related code?

I\'ve been using this "pattern" to lend structure to

2条回答
  •  别那么骄傲
    2021-01-02 05:54

    I always thought labels were cool:

    hideStuffOnInstantiaton: {
      $('oneThing').hide().removeClass();
      $('#somethign_else').slideUp();
      $('.foo').fadeOut();
    }
    

    In reality, it's usually silly to do this. Instead, grouped functionality generally belongs in its own function.

提交回复
热议问题