question/implement-once #41
Replies: 1 comment
-
/**
* @param {Function} func
* @return {Function}
*/
function once(func) {
let called = false;
let result;
return function () {
if (called) return result;
result = func.apply(this, arguments);
called = true;
return result;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
question/implement-once
北美前端面试攻略
https://us-fe.github.io/question/implement-once.html
Beta Was this translation helpful? Give feedback.
All reactions