function Test(){
var name = 'test'//私有
this.age = 12//公有
this.getName = function(){
return name
}
this.getAge = function(){
return this.age
}
}
var Test = new Test()
print(Test.name)//undefined
print(Test.age)//12
print(Test.getAge())//12
print(Test.getName())//'test'
模块模式
var singleton = function(){
//私有变量和函数
var privateVariable = 10
function privateFunction(){
return false
}
//创建对象
var object = new CustomType()
object.publicProperty = true;
object.publicMethod = function(){
privateVariable++
return privateFunction()
}
return object;
//特权/公有方法和属性
// return {
// publicProperty:true,
// publicMethod:function(){
// privateVariable++
// return privateFunction()
// }
// }
}()
//单例接口
va