jQuery function declaration explanation

前端 未结 4 1924
-上瘾入骨i
-上瘾入骨i 2021-01-22 22:09

I\'ve opened jQuery 1.7.1 library and wanted to study the code, but I\'ve found a that functions are declared in strange way (for me). For example:

show: functio         


        
4条回答
  •  不思量自难忘°
    2021-01-22 22:49

    they're being described as a js object function. In this case:

    var jQuery = {
        show: function(){
            //some code here
        }
    }
    

    so you access it like jQuery.show() for example.

    I would say Chad's answer is most accurate for in depth research. You should look into them as they can revolutionize how you write js in a very clean way that is much less likely to conflict with other libraries.

提交回复
热议问题