zoukankan      html  css  js  c++  java
  • javascript面向对象编程(一)


    <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>

  • 相关阅读:
    边缘检测(13)
    图像梯度
    高斯金字塔和拉普拉斯金字塔(十一)
    轮廓发现(16)
    圆检测(15)
    直线检测(14)
    图像腐蚀与图像膨胀(18)
    go语言从例子开始之Example18_1.结构体中定义方法
    go语言从例子开始之Example18.struct结构体
    go语言从例子开始之Example17.指针
  • 原文地址:https://www.cnblogs.com/myself/p/1764700.html
Copyright © 2011-2022 走看看