Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IE11:javascript中的三元“排序”抛出语法错误_Javascript_Sorting_Internet Explorer_Internet Explorer 11_Ternary Operator - Fatal编程技术网

IE11:javascript中的三元“排序”抛出语法错误

IE11:javascript中的三元“排序”抛出语法错误,javascript,sorting,internet-explorer,internet-explorer-11,ternary-operator,Javascript,Sorting,Internet Explorer,Internet Explorer 11,Ternary Operator,我有一个简单的排序函数 data.sort((a, b) => (b.alreadyExists) ? 1 : -1); 这在Chrome和JSFiddle中都可以正常工作,但在IE11中却不行:我是做错了什么,还是这只是IE11中令人讨厌的事情之一 不幸的是,这里没有使用IE11的选项:IE不支持。在IE 11中,您可以编写如下函数: data.sort(function (a, b) { return b.alreadyExists ? 1 : -1; }); 不要在IE

我有一个简单的排序函数

data.sort((a, b) => (b.alreadyExists) ? 1 : -1);
这在Chrome和JSFiddle中都可以正常工作,但在IE11中却不行:我是做错了什么,还是这只是IE11中令人讨厌的事情之一

不幸的是,这里没有使用IE11的选项:

IE不支持。在IE 11中,您可以编写如下函数:

data.sort(function (a, b) {
    return b.alreadyExists ? 1 : -1;
});

不要在IE 11:中使用箭头功能,或使用将其传输到兼容版本: