Polyfill: apply()

polyfill function that replicates the behavior of the built-in Function.prototype.apply() method.

Asked in frontend interviews at Meta, Uber and Amazon