JavaScript Double Dollar Sign

后端 未结 5 2170
别那么骄傲
别那么骄傲 2020-11-29 06:54

I understand the use of the (single) dollar sign in popular JavaScript libraries such as jQuery and Prototype. I also understand the significance of the double dollar sign i

5条回答
  •  离开以前
    2020-11-29 07:39

    Well really, it's just the naming convention of the developer. "$$" might as well as be "aa", for all intents and purposes.

    As you mentioned, the single dollar sign function $() has become almost-standard in various JavaScript libraries. "The one function to rule them all", eh? But remember, it's nothing inherent to JS itself. It's just a function name that caught on to replace document.getElementById().

    So, with that said, $$ could be anything. Heck, you could even have a function like this:

    function $$$$$$$$(){
      //i've got dollar signs in my eyes!
    }
    

    In other words, it's just a variable/function name—just like all the rest.

提交回复
热议问题