The values function in the Underscore.js library can be used to extract the values from an object and return them in an array. Here is an example usage of values in javascript:
index.tsx286 chars11 linesIn the above code, we first include the Underscore library using the require function. We then define an example object obj, which contains key-value pairs. Finally, we use the values function to extract the values from obj and store them in an array called arr. The output of this code is an array containing the values [1, 2, 3].
Note that the values function works with both arrays and objects. When used with an array, it simply returns a copy of the array.
gistlibby LogSnag