object.keys() returns an array of keys not values
my question is: why sort and filter methods can access the values of these keys?
or the keys contains the values somehow…!
sorry if i sounded stupid but when i try to log the object.key(counts) alone and both highest and mode ,it seems like they get the values somehow from an array of keys only.
const counts = { '1': 11, '2': 5, '4': 11 };
const highest = Object.keys(counts).sort(
(a, b) => counts[b] - counts[a]
)[0];
const mode = Object.keys(counts).filter(
(el) => counts[el] === counts[highest]
);
console.log(mode);