Menu

gitpiper

spreadOver javascript Code Snippet in 2024

functionintermediate

Last Updated: 20 April 2024

Takes a variadic function and returns a function that accepts an array of arguments.

  • Use a closure and the spread operator (...) to map the array of arguments to the inputs of the function.
const spreadOver = fn => argsArr => fn(...argsArr);
const arrayMax = spreadOver(Math.max); arrayMax([1, 2, 3]); // 3

javascript snippet similar to spreadOver For You in April 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️