Posted in Javascript onJune 25, 2010
<script type="text/javascript"> var test = { numA: 10, objB: {}, arrC: [], init: function(){ alert(this.numA); }, sayHi: function(name){ alert("hello " + name); }, sayHelloWorld: function(){ this.sayHi("world"); }, get: function(){ var self = this; this.objB.alertNumA = function(){ alert(self.numA); } } }; var TestFunc = function(){ alert("i'm testFunc"); }; TestFunc.prototype = { extFunc: function(){ alert("this extend function's numB is " + this.numB); }, numB: 10 }; test.init(); test.sayHi("qingming"); test.sayHelloWorld(); test.get(); test.objB.alertNumA(); var testFunc = new TestFunc(); testFunc.extFunc(); </script>
javascript面向对象编程(一) 实例代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@