< SCRIPT LANGUAGE = " JavaScript " > <!-- myClass = new function () // 区别之处 ... { var isLock=false; function check(str) ...{ if(isLock) ...{ alert('lock!'+" Go this way in "+str); return false; } return true; } function reset() ...{ isLock=true; } this.property1='property1'; this.method=function() ...{ alert('mothod'); } this.method1=function(str) ...{ if(!check(str))return; isLock=true; } } alert(myClass.property1); myClass.method(); myClass.method1( " first " ); myClass.method1( " second " ); // --> </ SCRIPT > < SCRIPT LANGUAGE = " JavaScript " > function myClass() // ... { var isLock=false; function check(str) ...{ if(isLock) ...{ alert('lock!'+" Go this way in "+str); return false; } return true; } function reset() ...{ isLock=true; } this.property1='property1'; this.method=function() ...{ alert('mothod'); } this.method1=function(str) ...{ if(!check(str))return; isLock=true; } } var obj = new myClass(); alert(obj.property1) obj.method(); obj.method1( " first " ); obj.method1( " second " ); </ SCRIPT >