Emulate `arguments` object in JavaScript’s “fat” arrow functions
Jul 23, 2017 · 1 min read
Arrow functions in JavaScript (unlike regular functions) do not have their own arguments object ¹ but they can be emulated with the spread operator:
const return_args = (...args) => argsreturn_args(7,"the cake is a lie",27) //> [7,"the cake is a lie",27]
args is a regular Array with all of its pros and cons.
I learned this trick from this Stack Overflow answer.
