• JavaScript 中的类方法,对象方法,Prototype方法


     1 <script type="text/javascript">
     2  function baseClass()
     3 {
     4     this.showMsg = function()
     5     {
     6         alert("baseClass::showMsg");   
     7     }
     8    
     9     this.baseShowMsg = function()
    10     {
    11         alert("baseClass::baseShowMsg");
    12     }
    13 }
    14 baseClass.showMsg = function()
    15 {
    16     alert("baseClass::showMsg static");
    17 }
    18 
    19 function extendClass()
    20 {
    21     this.showMsg =function ()
    22     {
    23         alert("extendClass::showMsg");
    24     }
    25 }
    26 extendClass.showMsg = function()
    27 {
    28     alert("extendClass::showMsg static")
    29 }
    30 
    31 extendClass.prototype = new baseClass();
    32 var instance = new extendClass();
    33 
    34 instance.showMsg(); //显示extendClass::showMsg
    35 instance.baseShowMsg(); //显示baseClass::baseShowMsg
    36 instance.showMsg(); //显示extendClass::showMsg
    37 
    38 baseClass.showMsg.call(instance);//显示baseClass::showMsg static
    39 
    40 var baseinstance = new baseClass();
    41 baseinstance.showMsg.call(instance);//显示baseClass::showMsg
    42 </script>
  • 相关阅读:
    移动端的头文件
    时间倒计时
    H5 判断应用是否打开或是下载
    创建 XMLHttpRequest 对象
    JS 发送POST
    总结题
    uploadify 插件,去了进度条
    PC 拖动 以百分比计算
    pc 拖动效果,拖动带范围
    spring.net 在demo中的分析
  • 原文地址:https://www.cnblogs.com/lvyongbo/p/4468173.html
Copyright © 2020-2023  润新知