JavaScript differences local/device?

I’m trying to use the Q js library ( with fuse. It works on iOS but fails in local preview on OSX.

The error I’m getting is TypeError: Reduce of empty array with no initial value, and I think I have boiled down the problem to be different handling of undefined.

This short example throws an error in local preview, but not on iOS. I don’t have an Android device available, so I’m not able to test on that at the moment.

        var result = [].reduce(function() {}, undefined);
        debug_log("result " + result);

The error stems from deep down inside Q, and I think the point of the code is to return undefined when calling reduce on an empty array.

For now I’ll try to use a different promise library, but any hints on the source of the error would be appreciated.

Thanks for posting, reduce is definitely a ES 5.1 feature, so should be supported, I will take a look.

I can reproduce the error message on both Windows and Mac preview. We are working on switching the javascript engine to v8 in preview, that will fix this error.