您好,欢迎访问一九零五行业门户网

JavaScript中数组的合并以及排序实现示例_基础知识

合并两个数组 - concat()
源代码:
​点击按钮合并数组。
​点我​​
测试结果:
cecilie,lone,emil,tobias,linus
合并三个数组 - concat()
源代码:

测试结果:
jani,tove,stale,kai jim,borge,cecilie,lone
数组排序(按字母顺序升序)- sort()
源代码:
​click the button to sort the array.
​try it​​
测试结果:
apple,banana,mango,orange
数字排序(按数字顺序升序)- sort()
源代码:
​click the button to sort the array.
​try it​​
测试结果:
1,5,10,25,40,100
数字排序(按数字顺序降序)- sort()
源代码:
​click the button to sort the array.
​try it​​
测试结果:
100,40,25,10,5,1
将一个数组中的元素的顺序反转排序 - reverse()
源代码:
​click the button to reverse the order of the elements in the array.
​try it​​
测试结果:
mango,apple,orange,banana
其它类似信息

推荐信息