We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
执行下面的代码后,arr数组的值为__________。
var arr = [4, 1, 5, 2, 3]; arr.sort(function(a, b) { return a > b; });
The text was updated successfully, but these errors were encountered:
[4, 1, 5, 2, 3] 因为 sort接受的函数返回值 ,有效值只能是一个负数、零或正数,。 正确标准的写法是 a - b 或者b-a 。a>b 产生一个布尔值,js有隐式转换,true false 转成1 0 那么排序就混乱了, 0代表顺序无关紧要,也就不改变了。
Sorry, something went wrong.
No branches or pull requests
执行下面的代码后,arr数组的值为__________。
The text was updated successfully, but these errors were encountered: