了解JavaScript中不同类型的函数
请看下面的代码片段,代码中还有注释(我的理解)。请告诉我我对下面函数的理解是否正确了解JavaScript中不同类型的函数,javascript,jquery,Javascript,Jquery,请看下面的代码片段,代码中还有注释(我的理解)。请告诉我我对下面函数的理解是否正确 function MyViewModel() { this.DisplayInside = function () { //Is this someting like a public method can be called out side MyViewModel console.log("DisplayInside"); } var
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脚本中实现oops概念。1)是2)3)是4)定义“更好”谢谢你的回答。我所说的“更好”是指在java脚本中实现oops概念的更好方法。使用设计语言。不要试图强化你在其他语言中可能学到的概念。