JavaScript: Get the Min/Max Values in an Object
Published : 2nd March 2022 | by @faisaljebali

In this article I will show you how to get max/min value in an object.
To get the min and max values in an Object:
Use the
Object.values
Using spread syntax, pass the array to the Math.min() and Math.max() methods.
The Math.min and Math.max methods return the lowest and highest of the passed in numbers.
const obj = {num1: 10, num2: 20, num3: 5, num4: 15};
const values = Object.values(obj);
console.log(values); // 👉️ [10, 20, 5, 15]
const max = Math.max(...values);
console.log(max); // 👉️ 20
const min = Math.min(...values);
console.log(min); // 👉️ 5