确保只调用一次函数

function once (fn) {
  var called = false;
  return function () {
    if (!called) {
      called = true;
      fn.apply(this, arguments);
    }
  }
}
posted @ 2018-05-07 11:25  FE-神鸟  阅读(445)  评论(0编辑  收藏  举报