[2020-01-11] Call a Dynamic Function with Dynamic Params

Useful for wrapper APIs or communicating with external interfaces: Note: This won't work in a strict mode.

function callFunction(fn, ...rest) {
  this[fn].apply(this, rest)
}
callFunction('alert', 'Ping')
callFunction('setTimeout', () => alert('Timeout after 1s'), 1000)
Edit on GithubPublished on 2020-01-11

Copyright © 2019...2020 Nick S. Plekhanov