[removed] global scope

前端 未结 4 652
一个人的身影
一个人的身影 2021-02-03 12:15

Nowdays, i create a .js file with a lot of functions and then I link it to my html pages. That\'s working but I want to know what\'s the best way (good practices) to insert js i

4条回答
  •  一整个雨季
    2021-02-03 12:51

    A simple idea is to use one object that represents your namespace:

    var NameSpace = {
        Person : function(name, age) {
    
        }
    };
    
    var jim= new NameSpace.Person("Jim", 30);
    

提交回复
热议问题