zoukankan      html  css  js  c++  java
  • javascript笔记整理(对象的继承顺序、分类)

    Object.prototype.say=function(){
        alert("我是顶层的方法");
    }
    children.prototype
    =new parent(); parent.prototype.say=function(){ alert('我是父类原型'); } function parent(){ this.say=function(){ alert('我是父类'); } } children.prototype.say=function(){ alert('我是子类原型') } function children(){ //**** this.say=function(){ alert('我是子类'); } } var one=new children(); alert(one.say); //弹出: *部分

     继承顺序由下到上,需注意之类原型的位置,在继承父类之后.

    对象的分类

    1.内置对象

    1.1、Global

    实际上不存在,JavaScript中所有的函数都必须是某个对象的方法。例如  isNaN(),parseInt() 等方法都是Global对象的方法。

    1.2、Math( 格式:Math.方法(参数) )

    //取绝对值:Math.abs()
    var a=-23;
    alert(Math.abs(a));    结果:23
    
    //取近似整数(四舍五入):Math.round()
    var a=-2.4;
    alert(Math.round());    结果:2
    
    //取近似整数(下取舍):Math.floor()
    var a=2.9;
    alert(Math.floor());    结果:2
    
    //取近似整数(上取舍):Math.ceil()
    var a=2.1;
    alert(Math.ceil());    结果:3
    
    //最大值:Math.max()
    var a=2.1;var b=3.3
    alert(Math.max(a,b));    结果:3.3
    
    //最小值:Math.min()
    var a=2.1;var b=3.3
    alert(Math.min(a,b));    结果:2.1
    
    //随机数(0~1之间):Math.random()
    //取0-10之间整数
    alert(Math.round(Math.random()*10));

    2.本地对象(详细的W3C有介绍,这里就不阐述了)

    2.1.Array

    2.2.Number

    2.3.String

    2.4.Boolean

    2.5.Function

    2.6.RegExp

    ...

    3.宿主对象(之后会有专门的文章介绍这两个对象

    DOM——通过 DOM,可以访问所有的 HTML 元素,连同它们所包含的文本和属性

    BOM——浏览器对象模型

  • 相关阅读:
    org.hibernate.annotationexception no identifier specified for entity
    PL/SQL Developer 中文乱码解决
    cron表达式
    mysql远程连接的设置
    linux查看端口对应的程序及pid
    安卓开发分享功能,分享到facebook网页上不显示图片的问题
    win7下解压安装mysql的方法
    总结一下论文写作过程中的一些东西
    java中可以让程序暂停几秒执行的代码
    Neo4j图数据库使用
  • 原文地址:https://www.cnblogs.com/chenrf/p/4956695.html
Copyright © 2011-2022 走看看