摘要:
突然想写一个日历插件发现Date对象的一些常识快忘光了,复习一下 new Date()返回当前时间 年月日 getFullYear() 返回年份 getMonth() 返回月份(因为从0开始算 所以要+1) getDay() 返回星期几 getDate() 返回日期 new Date(2017,0, 阅读全文
摘要:
function factorial(n){ if( n === 1) return n; return n factorial(n 1); } function factorial(n,total){ if( n === 1 ) return total; return factorial(n 1 阅读全文
摘要:
```
function foo() { var a = 5; return { getA:function() {return a} } }
foo().getA
``` ```
function Foo() { var a = 5; var b = 6; this.getName = function() { return a+b }
}
und... 阅读全文
摘要:
首先简单粗暴的从例子中看概念 通过以上两个例子我们发现call可以干什么? 调用call() 传递的参数中的函数和属性 定义call() 传递的参数中的函数和属性 为什么call 可以调用 定义 别人的属性和方法?举个例子 a.call(b) 1. 函数a被执行 2. a中的this被指向b,a要用 阅读全文
摘要:
在线演示地址:https://jsfiddle.net/PiPiLu/8a7596Lp/ 阅读全文