UNPKG
tframe-utility
Version:
latest (8.0.58)
8.0.58
8.0.57
8.0.56
8.0.55
8.0.54
8.0.53
8.0.52
8.0.51
8.0.50
8.0.49
8.0.48
8.0.47
8.0.46
8.0.45
8.0.44
8.0.43
8.0.42
8.0.40
8.0.39
8.0.38
8.0.37
8.0.36
8.0.35
8.0.34
8.0.33
8.0.32
8.0.31
8.0.30
8.0.29
8.0.28
8.0.27
8.0.26
8.0.25
8.0.24
8.0.23
8.0.22
8.0.21
8.0.20
8.0.19
8.0.18
8.0.17
8.0.16
8.0.15
8.0.14
8.0.13
8.0.12
8.0.11
8.0.10
8.0.9
8.0.8
8.0.7
8.0.6
8.0.5
8.0.4
8.0.3
8.0.2
8.0.1
8.0.0
minimal unit of smpoo tframe platform
github.com/fanzouguo/tframe-utility
fanzouguo/tframe-utility
tframe-utility
/
preArr
/
index.js
15 lines
(13 loc)
•
422 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* 交互数组元素中指定索引位置的两个元素(改变原数组)
@arr
: 要操作的原始数组
@idx
1: 第一项要交换的元素的位置索引
@idx
2:第二项要交换的元素的位置索引 return:被改变后的原始数组 */
let swapItems =
function
(
arr, idx1, idx2
)
{ arr[idx1] = arr.
splice
(idx2,
1
, arr[idx1])[
0
];
return
arr; }; module.exports = { swapItems };