The lodash values method is one of many methods in lodash where there is a native counterpart. However sometimes browser support for a native method only goes back so far, also sometimes a native method does not always work as expected, or it could use one more additional feature that is just not there. However the lodash values object method might not be the best example of the kind of method in lodash that brings something more to the table, as the lodash values method does more or less the same thing as the Object values method. However when it comes to going way back the native Object.values method is still fairly new, and as such the use of the Object values native method will result in code breaking in certain older browsers.
In this section I will be starting out with a few basic examples of the lodash values method as well as other lodash methods such as the keys method. In a later section in this post I will be getting into the various native methods that there are to work with also, as well as how to go about poly filling the method and go about using alternatives that will work on very old web browsers.
The lodash values method works by just passing an object to it as the first argument, and then an array of values for each public keys is returned. There is also the lodash keys object method as well that does the same thing but returns the key public key names of the object.
The lodash keys method is just like that of the object values method but it will return an array of key names rather than that of values.
So then there is now the native Object.values method that was introduced in recent years, this method works in the same way as lodash values but it might not be there in some older environments. As such this is one such method that helps to support a case that lodash is not a dead library just yet depending on your sites bowser user agent stats. In addition to the native Object values method there is also an Object.keys method that works just like lodash keys.
If for some reason you really want to push support back very far, it would be best to work out a custom method that makes use of a for in loop. This is just simply the tired yet true way of going about getting all the values of an object.
The Object.defineProperty method can be used to define properties of an object that can not be enumerable. What this means is that they will not show up with Methods like the Object.values method. Also they will not show up in other typical ways of getting an array of object keys such as in a for in loop. So then in order to get these kinds of values I will need to work out some kind of situation involving the use of the get own property names method which will give me all the object keys including ones that are not enumerable.