const myObj = {a: 1, b: 2, c: 3}; const myArr = _.toArray(myObj); console.log(myArr); // Output: [1, 2, 3]
function myFunction() { const myArgsArray = _.toArray(arguments); console.log(myArgsArray); // Output: [1, 2, 3] } myFunction(1, 2, 3);In this example, we define a function that takes an arbitrary number of arguments. We use the built-in `arguments` object to get all the arguments passed to the function, and then use the _.toArray function to convert them to an array. The resulting array only contains the values. Package library: Underscore.