# 📝 Function Transformations āϕ⧀? JavaScript-āĻ Function Transformation āĻŦāϞāϤ⧇ āĻŦā§‹āĻāĻžāύ⧋ āĻšā§Ÿ āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύāϕ⧇ āχāύāĻĒ⧁āϟ āĻšāĻŋāϏ⧇āĻŦ⧇ āύāĻŋā§Ÿā§‡ āφāϰ⧇āĻ•āϟāĻŋ āύāϤ⧁āύ āĻĢāĻžāĻ‚āĻļāύ āϤ⧈āϰāĻŋ āĻ•āϰāĻž, āϝ⧇āϟāĻž āφāϗ⧇āϰ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āφāϚāϰāĻŖ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ (transform) āĻ•āϰ⧇āĨ¤ ## āϝ⧇āĻŽāύ: - compose: āĻāĻ•āĻžāϧāĻŋāĻ• āĻĢāĻžāĻ‚āĻļāύāϕ⧇ āĻāĻ•āĻ¤ā§āϰāĻŋāϤ āĻ•āϰ⧇ āύāϤ⧁āύ āĻĢāĻžāĻ‚āĻļāύ āĻŦāĻžāύāĻžāύ⧋āĨ¤ - once: āĻāĻ•āϟāĻŋ āĻĢāĻžāĻ‚āĻļāύāϕ⧇ āĻāĻŽāύāĻ­āĻžāĻŦ⧇ āĻŽā§‹ā§œāĻžāύ⧋ āϝāĻžāϤ⧇ āϏ⧇āϟāĻŋ āĻāĻ•āĻŦāĻžāϰāχ āϚāϞ⧇āĨ¤ - argumentsLength: āĻĢāĻžāĻ‚āĻļāύ āĻ•āϞ⧇āϰ āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϏāĻ‚āĻ–ā§āϝāĻž āĻŦ⧇āϰ āĻ•āϰāĻžāĨ¤ - memoize: āφāϗ⧇āϰ āĻĢāϞāĻžāĻĢāϞ āĻŽāύ⧇ āϰ⧇āϖ⧇ āĻĒāϰ⧇āϰ āĻŦāĻžāϰ āĻĻā§āϰ⧁āϤ āϰāĻŋāϟāĻžāĻ°ā§āύ āĻ•āϰāĻžāĨ¤ - debounce/throttle: āĻĢāĻžāĻ‚āĻļāύ āĻ•āϞ⧇āϰ āĻĢā§āϰāĻŋāĻ•ā§‹ā§Ÿā§‡āĻ¨ā§āϏāĻŋ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āĻ•āϰāĻžāĨ¤ # đŸŽ¯ āωāĻĻāĻžāĻšāϰāĻŖāϏāĻŽā§‚āĻš (Function Transformation) ## 1ī¸âƒŖ Function Composition (āĻĢāĻžāĻ‚āĻļāύ āĻāĻ•āĻ¤ā§āϰ āĻ•āϰāĻž) ```js var compose = function(functions) { return function(x) { return functions.reduceRight((acc, fn) => fn(acc), x); } }; ``` ## 2ī¸âƒŖ Allow One Function Call (āĻāĻ•āĻŦāĻžāϰāχ āϚāĻžāϞāĻžāύ⧋ āϝāĻžāĻŦ⧇) ```js var once = function(fn) { let called = false; let result; return function(...args) { if (!called) { called = true; result = fn(...args); return result; } return undefined; }; }; ``` ## 3ī¸âƒŖ Count Arguments (āφāĻ°ā§āϗ⧁āĻŽā§‡āĻ¨ā§āĻŸā§‡āϰ āϏāĻ‚āĻ–ā§āϝāĻž āĻŦ⧇āϰ āĻ•āϰāĻž) ```js var argumentsLength = function(...args) { return args.length; }; ``` ## 4ī¸âƒŖ Memoize (āĻĢāϞāĻžāĻĢāϞ āĻŽāύ⧇ āϰāĻžāĻ–āĻž) ```js var memoize = function(fn) { const cache = {}; return function(...args) { const key = JSON.stringify(args); if (key in cache) return cache[key]; cache[key] = fn(...args); return cache[key]; }; }; ``` ## 📚 āϏāĻžāϰāϏāĻ‚āĻ•ā§āώ⧇āĻĒ Function Transformations āĻŽāĻžāύ⧇ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āωāĻĒāϰ āĻĢāĻžāĻ‚āĻļāύ āϚāĻžāϞāĻžāύ⧋ āĻŦāĻž āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āφāϚāϰāĻŖ āĻŦāĻĻāϞ⧇ āύāϤ⧁āύ āĻĢāĻžāĻ‚āĻļāύ āĻŦāĻžāύāĻžāύ⧋āĨ¤ āĻāϗ⧁āϞ⧋ JavaScript-āĻāϰ Functional Programming āĻ¸ā§āϟāĻžāχāϞ⧇ āϖ⧁āĻŦ āϜāύāĻĒā§āϰāĻŋ⧟āĨ¤