Skip to content

Instantly share code, notes, and snippets.

@think2011
Created May 9, 2017 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save think2011/b44185d89ea914f3436974e213fe0046 to your computer and use it in GitHub Desktop.
Save think2011/b44185d89ea914f3436974e213fe0046 to your computer and use it in GitHub Desktop.
交换数组的位置
/**
* 交换数组的位置
* @param arr
* @param i {Number} 旧的位置
* @param j {Number} 新的位置
* @returns {*}
*/
function swap(arr, i, j) {
let tmp = arr[i]
arr[i] = arr[j]
arr[j] = tmp
return arr
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment