简体   繁体   中英

Uncaught SyntaxError in javascript function

I am trying to use the below function in my code which is running in cordova android application but getting syntax error: "Uncaught SyntaxError: missing ) after argument list" which pointing at:

[src, gainNode, dst].reduce((a, b) => a && a.connect(b));

Here is a function:

function modifyGain (stream, gainValue){

var audioTrack = stream.getAudioTracks()[0];
var ctx = new AudioContext();
var src = ctx.createMediaStreamSource(new MediaStream([audioTrack]));
var dst = ctx.createMediaStreamDestination();
var gainNode = ctx.createGain();
gainNode.gain.value = gainValue;
[src, gainNode, dst].reduce((a, b) => a && a.connect(b)); // syntax error on this line
stream.removeTrack(audioTrack);
stream.addTrack(dst.stream.getAudioTracks()[0]);

};

Here is my browser info:

5.0 (Linux; Android 4.4.4; D5503 Build/14.4.A.0.108) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Crosswalk/15.44.384.12 Mobile Safari/537.36

It is working fine on chrome 51 on my mac but give syntax error in android phone. Can someone tell me a reason and how i can simplyfy this rather than using expression.

尝试用ES5语法编写此行代码

[src, gainNode, dst].reduce( function(a, b) { return a && a.connect(b) });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM