const x = [new Date(), 1663761716, (new Date()).toJSON()];
const y = x.map((v) => new Date(v));
console.log(y);
The code above transforms an array of Date, number, string into an array of 3 Dates.
My question is the second line. Of course it is already short enough, but it feels stupid to call a function in a lambda with the same parameter. There should be something like:
const y = x.map(Date.constructor);
But this doesn't work. Is there any way to pass a constructor as a parameter?