[removed] Best way to declare functions to be used globally?

前端 未结 3 993
长发绾君心
长发绾君心 2021-02-04 06:20

My javascript file is getting pretty big (3000+ lines) and I\'m getting confused as to how to layout my file and delare functions so that they can called anywhere in the

3条回答
  •  故里飘歌
    2021-02-04 07:00

    You can either declare them in Window scope:

    window.variableName = myVariable;
    

    or you can omit the var, which is the same as declaring something in window scope:

    variableName = myVariable;
    

提交回复
热议问题