jQuery best practices in case of $('document').ready

前端 未结 9 1284
孤街浪徒
孤街浪徒 2020-12-07 11:35

I was researching on jQuery best practices and found this article by Greg Franko

Normally, I do:

$(\"document\").ready(function() {
    // The DOM i         


        
9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 11:56

    It's called a self ivoking or immediately invoked function. It means that the function is run as soon as it is created using the parameters in the final set of brackets.

    Read Javascript Self Invoking Functions and Immediately-Invoked Function Expression (IIFE) will clear where to use and how to use these functions

提交回复
热议问题