Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including fast-apply with all npm packages installed. Try it out:

var fastApply = require("fast-apply")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

fast-apply v0.0.3

Apply an array of arguments... faster


Apply an array of arguments... faster.

var fastApply = require('fast-apply')
  , scope = {}

function run() {}

fastApply(run, scope, [ 'a', 'b', 'c' ]);


$ npm install fast-apply




It uses a simple switch statement to call the function rather than apply for up to 5 arguments.

While more than 5 arguments would run faster using apply, anything less will be up to twice as fast

If the scope is null, fastApply will run up to 3 times faster than apply


  • It is only optimized for 5 arguments or less. If you think the function will frequently be taking more than 5 arguments, I suggest that you instead use apply


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free