zoukankan      html  css  js  c++  java
  • JS第三堂课

    Javascript(三)

    1、 函数

    function functionName(arg1,arg2…)

    {

      …..

    }

    return语句用法

    2、 对象

    属性/方法

    var aValues=new Array();

    var myString=new String(“hello world”);

    3、 Date对象(var myDate=new Date())

    1) 计算程序执行速度(得到毫秒数)1.html

    2) 方法

    方法

    描述

    getFullYear()

    返回四位数的年份

    getMonth()

    返回月份(当前的月份-1)

    getDate()

    返回日期(从1开始)

    getDay()

    返回星期几(星期天0)

    getHours()

    返回小时数(从1开始)

    getMinutes()

    返回分钟数(从1开始)

    getSeconds()

    返回秒数(从1开始)

    getMilliseconds()

    返回毫秒数(从0开始)

    getTime()

    返回从GMT时间1970年1月1日0点0分0秒经过的毫秒数

    获取当前时间:2.html

    获取相差天数:3.html

    4、 Math对象

    1) 属性

    Math.LN10

    10的自然对数

    Math.LN2

    2的自然对数

    Math.LOG2E

    以2为底E的对数

    Math.LOG10E

    以10为底E的对数

    Math.PI

    圆周率

    Math.SQRT1_2

    1/2的平方根

    Math.SQRT2

    2的平方根

    2) 方法

    取最大值:Math.max(18,12,22,33)

    取最小值:Math.min(18,2,2,3,1)

    向上舍入:Math.ceil(25.9) //它把数字向上舍入到最接近的整数

    向下舍入:Math.floor(25.6)

    四舍五入:Math.round(25.6)

    0~1之间的随机数:Math.random() //不包括0和1

    var iNum=Math.floor(Math.random()*100+1) //返回1~100之间的整数包括1和100

    其他方法

    5、 window对象

    1) window.open("http://www.baidu.com", "_blank", "height=300,width=400,top=30,left=140,resizable=yes");

    resizable 是否能通过拖动来调整新窗口的大小 默认为yes

    scrollable 新窗口是否显示滚动条 默认为no

    2) 关闭新建的窗口

    Window.close()

    3) alert()、confirm()、prompt()

    confirm(“确定删除?”) //返回布尔型

    4) window.history.go(-1) //浏览器后退一页

    window.history.go //前进一页

    也可以用:

    window.history.back()

    window.history.forward()

  • 相关阅读:
    牛逼哄哄的 RPC 框架,底层到底什么原理?
    你只会用 StringBuilder?试试 StringJoiner,真香!
    厉害了,淘宝千万并发,14 次架构演进…
    微服务中 Zookeeper 应用及原理
    牛逼哄哄的零拷贝是什么?
    排名前 16 的 Java 工具类,哪个你没用过?
    Spring Boot 2.4 正式发布,重大调整!!!
    pl/sql 实例精解 07
    ArcGIS 符号和样式
    SQL Server系统视图有什么用?
  • 原文地址:https://www.cnblogs.com/cd115703/p/5008610.html
Copyright © 2011-2022 走看看