Open
Description
JerryScript revision
2.4.0
Build platform
ubuntu20.04
Description
I executed the following test cases and found the resuts of jerry were different from other js engines.
The first test case should return an array sorted from smallest to largest, but jerry didn't sort the array.
The second test case takes an empty function as the parameter of sort(), and it should return the original array, while jerry returns a reversed array.
Looking foward to your reply.
Test case1
function foo1() {
foo2.prototype = arguments;
new foo2();
}
function foo2() {
var x = Array.prototype.sort.call(this);
for (var i = 0; i < x.length; i++) {
print(x[i]);
}
}
foo1(3,2,4,1);
Output
3
2
4
1
Expected behavior
1
2
3
4
Test case2
var a = [3, 2, 4, 1].sort(() => {});
for (var i = 0; i < a.length; i++) {
print(a[i]);
}
Output
1
4
2
3
Expected bahavior
3
2
4
1