Implement a function once(fn) that accepts a callback fn and restricts its invocation to at most once.
The function should:
fn only on the first invocation.fn again.Examples
const initialize = once(() => "initialized"); initialize(); // "initialized" initialize(); // "initialized" (same result, fn not called again)
JavaScript Function
No test results yet
Click "Run" to execute tests