javascript面向?qū)ο缶幊?一) 實例代碼
更新時間:2010年06月25日 00:48:50 作者:
javascript面向?qū)ο缶幊虒嵗a,代碼也算比較基礎了,不懂得朋友可以參考腳本之家之前發(fā)布的文章。
復制代碼 代碼如下:
<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實現(xiàn)單繼承和多繼承的簡單方法
JavaScript是一種強大的多泛型編程語言,其融合了面向過程、面向?qū)ο蠛秃瘮?shù)式編程于一身,具備強大的表現(xiàn)能力。2009-03-03

