how to return the key with the highest value in an object in javascript code example
Example 1: find in highest value key from an object javascript
var obj = {a: 1, b: 2, undefined: 1};
Object.keys(obj).reduce((a, b) => obj[a] > obj[b] ? a : b);
Example 2: which object key has highest value javascript
var obj = {a: 1, b: 2, undefined: 1};
Object.keys(obj).reduce((a, b) => obj[a] > obj[b] ? a : b);