源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

javascript面向对象编程(一) 实例代码

  • 时间:2021-09-17 19:15 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:javascript面向对象编程(一) 实例代码
[u]复制代码[/u] 代码如下:
<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>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部