I have this array of objects [{x:0, y:1}, {x:3, y:2}] in javascript.
I want to to get an array of x only (0, 3) using the spread operator ... so I can apply javascript Math.max after.
You don't want to spread, though, you want to map (and then spread the result). So do that:
Math.max(...input.map(_=>_.x));
You can use ES6 lambda function to achieve this. Please refer code below.
var input = [{"x":1,"y":2},{"x":3,"y":5},{"x":2,"y":2}];
console.log( Math.max( ...input.map(function(a){return a.x} ) ) );