一.获取日期对象的方法

//NO1 getFullYear() 获取当前的年
        console.log('当前的年:'+date.getYear()); //1900年开始
        console.log('当前的年:'+date.getFullYear());
//No2  getMonth()  获取月份 需要加一
        console.log('当前月份:'+(date.getMonth()+1));
 //No3  getDay()  获取星期
        console.log('当前的星期:'+date.getDay());
//No4  getDate()  获取日期
        console.log('当前的日期:'+date.getDate());
        console.log('-----------------');
//No5 getHours()  获取当前的时
        console.log('当前的时:'+date.getHours());
//No6 getMinutes() 获取当前的分钟
        console.log('当前的分钟:'+date.getMinutes());
 //No7 getSeconds() 获取当前的秒数
        console.log('当前的秒数:'+date.getSeconds());
 //No8 getMilliseconds() 获取当前的毫秒数
        console.log('当前的毫秒数:'+date.getMilliseconds());
        console.log('-----------------');
 //No9 getUTCHours() 获取标准时区的时
        console.log('标准时区的时:'+date.getUTCHours());
 //No10 getUTCMinutes() 获取标准时区的分
        console.log('标准时区的分:'+date.getUTCMinutes());
 //No11 toUTCString() 获取标准时区时间字符串
        console.log('标准时区的时间字符串:'+date.toUTCString());
        console.log('-----------------');
 //No12 获取时间戳
        console.log('当前的时间戳:'+date.getTime());

二.将时间戳转换为标准格式 

var date = new Date();
        //获取当前时间戳
 var t = date.getTime();
        document.write(t+"<br>");
        //1496989549308 ->  1466989549308
var oldtime = 1416989549308//获取一个以前的时间对象
var mydate = new Date(oldtime);
        console.log(mydate.getFullYear());
        console.log(mydate.getMonth()+1);
        console.log(mydate.getDate());

三.全局对象的常用方法

  1.isNaN(); 

  2.parseInt();

  3.parseFloat()  浮点型

  4. Number() String() Boolean() RegExp() .....

  5.eval()  可以将字符串作为代码来执行

  6.escape()  对字符进行转码

  7.unescape() 对escape的编码进行解码

  8.encodeURI()  针对url编码

  9.decodeURI()  对encodeURI的解码

  10. encodeURIComponent()  对URI进行编码

  11.decodeURIComponent() 对encodeURIComponent进行解码

四.错误处理中的错误类型

  1. 语法错误 SyntaxError 前后都不会执行

  2.引用错误  ReferenceError  前面执行 后面不执行

  3.范围错误 RangeError

  4.类型错误 typeError

五.错误处理中的处理方法

  1.避免错误

  2.try....catch语句

  3.finally 字句 

  4.调试

六.时间的绑定方法

  1.标准方式 

    //获取元素
        var btn = document.getElementById('btn');
        //绑定事件
        btn.addEventListener('click',show);

        function show(){
            alert('啊,我出来了。');
        }
        function demo(){
            alert('啊,我进去了.');
        }

  注:兼容问题

//IE8的绑定
        //btn.attachEvent('onclick',show);

        //写一个函数用于兼容绑定
        /*
        *传入三个参数 : dom,event,fn
        */
        function addEvent(dom,event,fn){
            if(dom.addEventListener){
                dom.addEventListener(event,fn);
            }else if(window.attachEvent){
                dom.attachEvent('on'+event,fn);
            }else{
                console.log('您的垃圾浏览器不支持事件');
            }
        }

  2.把事件作为元素的方法

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件绑定</title>
    <style>
        #box{
            width:300px;
            height:200px;
            border:1px solid #333;
            margin:0 auto;
        }
    </style>
</head>
<body>
    <button id="btn">点我</button>
    <hr>
    <div id="box"></div>
    <script>
        //事件绑定的第二种方法: 将事件作为元素的属性进行绑定
        var btn = document.getElementById('btn');
        var box = document.getElementById('box');

        btn.onclick = function(){
            alert('来啊,快活啊。。');
        }
        //同一个事件  不能绑定多次 会覆盖
        btn.onclick = function(){
            alert('来啊,相互伤害啊。。。');
            box.style.backgroundColor='green';
        }
    </script>
</body>
</html>

  3.把事件作为标签的内部属性  

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件绑定</title>
</head>
<body>
    <button onclick="show()" id="btn">点我</button>
    <script>    
        //事件绑定方式三: 事件属性
        function show(){
            alert('你愁啥,瞅你咋地?');
        }

        var btn = document.getElementById('btn');
        
        btn.onclick = function(){
            alert('大金链子小手表,一天三顿小烧烤.');
        }

    </script>
</body>
</html>

七.解除事件绑定

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件的解除</title>
</head>
<body>
    <button id="btn" onclick="show()">点击</button>
    <button id="butt">标准绑定</button>
    <button id="del">解除事件绑定</button>
    <script>
        var btn = document.getElementById('btn');
        var butt = document.getElementById('butt');
        var del = document.getElementById('del');

        //给第一个按钮绑定事件
        /*
        第二种方式  可以通过重新给函数赋值为空 解除事件
        btn.onclick = function(){
            console.log('触发了');
        }
*/
        /*第三种绑定方式也可以通过重新给函数赋值为空 解除事件*/
        function show(){
            console.log('触发了');
        }
        //标准方式绑定  使用函数重新赋值为空  不能解除事件
        butt.addEventListener('click',function(){
            console.log('标准绑定');
        })
        del.onclick = function(){
            btn.onclick = function(){};
            butt.onclick = function(){};
        }
    </script>
</body>
</html>