Middle+
How to convert arguments into an array in the old way (ES5), without Array.from and spread operator?
sobes.tech AI
Answer from AI
In ES5, to convert the arguments object into an array without using Array.from and the spread operator, you can use the Array.prototype.slice method:
function example() {
var args = Array.prototype.slice.call(arguments);
console.log(args);
}
example(1, 2, 3); // [1, 2, 3]
This method creates a new array by copying all elements from arguments. It was widely used before the advent of ES6.