大家好,我对JavaScript的面向对象编程不太熟悉,经过一些尝试后,我在对象定义方面有一些小困惑。请帮忙检查下面的代码和注释。谢谢。
GlobalUtility = function() {
this.templeteCode = "123";
this.Init();
//why can not put this code here,
//there is an error says GetOriginalSource is not a function .
//This is not like the classical OO constructor which can call any methods in class.
this.Init = function() {
var source=this.GetOriginalSource();
alert(source + " is ok.");
},//I found I can end this statement by , or ; Is there any difference between them?
this.GetOriginalSource=function(){
return "abc";
};
//this.Init(); putting this code here is ok .
};