JavaScript 专题之惰性函数

JavaScript 专题系列第十五篇,讲解惰性函数 需求 我们现在需要写一个 foo 函数,这个函数返回首次调用时的 Date 对象,注意是首次。 解决一:普通方法 var t; function foo() { if (t) return t;