Home

Awesome

array-swap

Swapping two items in a javascript array - Array.prototype.swap

Install

$ npm install --save array-swap

Usage

var swap = require('array-swap');

var arr = ['apple', 'orange', 'banana', 'pear'];
arr.swap(1, 3);

// arr will be
// ['apple', 'pear', 'banana', 'orange']

License

MIT © Marko Jankovic