37)

date类:

  var  time=new.date()

  get date()  返回一个月中的某一天

  get day ()  返回一周中的某一天

  get fullyear()  对象以四位数返回年份

  get hours() 返回对象的小时

  get minutes()  返回date对象的分钟

  get seconds()  返回date对象的秒数

  get time()  返回1970年1月1日至今的毫秒数

  get month()  从date对象返回年份(比实际情况小1)0代表一月

  parse()  返回1970年1月1日午夜距该日期时间的毫秒数  date.parse(“月份  日期 ,年份”) 

  

  set date()  设置date对象中的某一天(参数1-31)

  set fullyear()  设置年份(参数:(year ,moth,day))

  set month()  设置月份(参数:(moth,day))

  set hours()  设置小时数(参数:(hours,min,sec,millisec))

  set minutes()  设置分钟数(参数:(min,sec,millisec))

  set seconds()  设置秒数(参数:(sec,millisec))

创建date对象:

  var d=new date()  获取当前时间

  var d=new date(milliseconds)  一个到1970年1月1日的毫秒数对象

  var d=new date(datestring)  

  var d=new date(year,month,day,hours,minutes,seconds,milliseconds)

闭包:

  函数在调用的时候会形成一个私有作用域,对内部的变量起到保护作用,这就叫闭包

变量销毁:

  人为销毁  var a=12;  a=null;

  自然销毁  函数在调用完成之后,浏览器自动销毁函数内部的变量;

闭包作用:

  保护变量  缓存数据  

闭包种类:

  1,函数式:function fn{

        var a=3;

        function ff(){

          a++;

          console.log(a)

        } 

        ff()

      }

  ,2,对象式:function fn{

        var a=3;

        var obj={

          num:a

        }

          console.log(a)

       }

函数返回值的问题:

  每个函数都有一个返回值,如果人为返回,返回的什么就是什么;

  没有就是undefined;

猜你喜欢

转载自www.cnblogs.com/xiaotaiyangye/p/10156365.html
37