[removed] final / immutable global variables?

前端 未结 14 2062
既然无缘
既然无缘 2020-12-13 09:03

I think I know the answer but... is there any way to prevent a global variable from being modified by later-executing

14条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 09:13

    Javascript is object oriented, rather than making the variable $public static, consider making it private and then properly providing an acessor method for getting, but not setting it.

    e.g.

    private var myGlobal : myType;
    function GetMyGlobal() : myType
    {
    return myGlobal;
    }
    

    There are ten different ways to solve any given problem, your way and the right way.

提交回复
热议问题