What is most efficient / elegant way to achieve sql-like filtering effect. I want to filter them and get only that objects which are max value in some group.
This is
Doing this in stages.
Below is an example.
const input = [{"name":"bathroom","value":54,"timeStamp":1562318089713},{"name":"bathroom","value":55,"timeStamp":1562318090807},{"name":"bedroom","value":48,"timeStamp":1562318092084},{"name":"bedroom","value":49,"timeStamp":1562318092223},{"name":"room","value":41,"timeStamp":1562318093467}];
const output = [...new Set(input.map(m => m.name))].
map(m => [...input].sort(
(a,b) => b.value - a.value).
find(x => m === x.name));
console.log(output);