@extra-array/swap
v2.10.19
Published
Exchanges two values.
Downloads
462
Readme
Exchanges two values. :package: :smiley_cat: :running: :vhs: :moon: :scroll: :newspaper: :blue_book:
This is part of package extra-array.
array.swap(x, i, j);
// x: an array
// i: an index
// j: another index
const array = require("extra-array");
var x = [1, 2, 3, 4];
array.swap(x, 0, 1);
// [ 2, 1, 3, 4 ]
array.swap(x, 0, 3);
// [ 4, 2, 3, 1 ]