exe*_*ook 1 javascript sorting
function randOrd() {
return (Math.round(Math.random()) - 0.5)
}
A = [0,1,2,3,4,5,6,7]
var B = A.sort(randOrd)
console.log('A=',A)
console.log('B=',B)
Run Code Online (Sandbox Code Playgroud)
输出:
a= [ 3, 4, 0, 1, 6, 2, 5, 7 ]
b= [ 3, 4, 0, 1, 6, 2, 5, 7 ]
Run Code Online (Sandbox Code Playgroud)
我希望a是原始数组并b进行排序.但它们都是平等的(排序的),为什么?