Nirs Nirs - 5 months ago 12
Javascript Question

jquery map and Date() function

I had this js/jquery function working well with all browsers (to transform a timestamp to a date) but actually safari gives me a console error at the ">" character. Any one knows another way to get the same effect?

var newTimeArray = timeValues.map(t => new Date(t));

Answer

Arrow functions are still fairly new. The old fashioned syntax for this (which should work in all browsers) is

var newTimeArray = timeValues.map(function(t){
    return new Date(t);
});