For example:
var obj = {a: 1, b: 2, undefined: 1};
Object.keys(obj).reduce(function(a, b){ return obj[a] > obj[b] ? a : b });
In ES6:
var obj = {a: 1, b: 2, undefined: 1};
Object.keys(obj).reduce((a, b) => obj[a] > obj[b] ? a : b);
More Related Contents:
- javascript runs twice [closed]
- Test for existence of nested JavaScript object key
- Question mark and colon in JavaScript
- For loop for HTMLCollection elements
- Access Control Request Headers, is added to header in AJAX request with jQuery
- How to populate a cascading Dropdown with JQuery
- Difference between HTMLCollection, NodeLists, and arrays of objects
- Merge 2 arrays of objects
- Streaming a video file to an html5 video player with Node.js so that the video controls continue to work?
- node-request – Getting error “SSL23_GET_SERVER_HELLO:unknown protocol”
- How to create a simple map using JavaScript/JQuery [duplicate]
- match() returns array with two matches when I expect one match
- Accessing localStorage from a webWorker
- regex extract email from strings
- How to free up the memory in JavaScript
- How can I find a user’s country using HTML5 geolocation?
- javascript remove “disabled” attribute from html input
- How to get a number value from an input field?
- spread operator vs array.concat()
- How to append to New Line in Node.js
- ‘expo’ is not recognized as an internal or external command
- How to disable Javascript when using Selenium?
- What is the JavaScript equivalent of var_dump or print_r in PHP? [duplicate]
- Why is “👍”.length === 2?
- how to alert javascript object [duplicate]
- Get request url from xhr object
- jQuery selector to target any class name (of multiple present) starting with a prefix?
- Is there a function to deselect all text using JavaScript?
- Why do these two javascript 2d-arrays behave differently?
- Using a for each loop on an empty array in JavaScript [duplicate]