Once Polyfill
function once(fn, context) {
let ans;
return function (...args) {
if (fn) {
ans = fn.apply(context || this, args);
fn = null;
}
return ans;
};
}
const Hello = (name) => {
console.log("Hello", name);
};
const hello = once(Hello);
hello("Arju");
hello("Raju");
hello("John");
// Hello Arju