What is the difference between a dollar sign and a dollar sign followed by a period in JQuery?

前端 未结 5 1585
余生分开走
余生分开走 2021-01-12 10:48

In jQuery, what is the difference between $ and $.? Please provide a practical explanation if possible.

5条回答
  •  悲&欢浪女
    2021-01-12 11:12

    I presume you are asking about the syntactic difference between $('#selector'); and $.parseJSON(str);.

    The former is an invocation of a function called $ and the latter invokes it's method called parseJSON. Yup, functions can have methods - it is possible because Javascript functions are also objects. Figuratively speaking:

    
    

提交回复
热议问题