首页 > Web开发 > 详细

JS对象的使用

时间:2017-02-17 18:58:34      阅读:207      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>JS对象使用</title>
    <script type="text/javascript">
        //Date使用
        var date = new Date();//当前系统时间
        //获取年月日等
        document.write(date.toLocaleString()+"<br/>");
        document.write(date.getFullYear()+"<br/>");
        document.write(date.getDate()+"<br/>");
        document.write(date.getDay()+"<br/>");
        document.write(date.getMonth()+1+"<br/>");
        //有get,对应的就有set  设置各个值
        date.setFullYear(date.getFullYear()+1);
        document.write(date.getFullYear()+"<br/>");

        //Math使用
        document.write(Math.abs(-3.5)+"<br/>");//绝对值
        document.write(Math.ceil(-3.5)+"<br/>");//-3 向上取整
        document.write(Math.floor(-3.5)+"<br/>");//-4 向下取整
        document.write(Math.max(-3,9)+"<br/>");//9最大值
        document.write(Math.round(4.6)+"<br/>");//6  四舍五入

    </script>
</head>
<body>

</body>
</html>

  技术分享

 

JS对象的使用

原文:http://www.cnblogs.com/john568300/p/6411162.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!