所有,我对javascript OO不熟悉,在我做了一些实验之后,我对对象定义有些困惑,请帮助查看我的代码和下面的评论。谢谢。
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 .
};