请查看下面的代码片段,其中还有一些评论(我的理解)包含在代码中。请告诉我天气我对以下功能的理解是否正确?
function MyViewModel() {
this.DisplayInside = function () { //Is this someting like a public method can be called out side MyViewModel
console.log("DisplayInside");
}
var DisplayInside = function () { ///Is this someting like a private method can be called within MyViewModel
console.log("DisplayInside");
}
}
MyViewModel.DisplayOutSide = function () { //Is this someting like a public static method
console.log("DisplayOutSide");
}
$(document).ready(function () {
MyViewModel.DisplayOutSide(); //Call the static method
var model = new MyViewModel();
model.DisplayInside(); //Call the function using object
});
有没有更好的方法在java Script中实现oops概念。