-
Notifications
You must be signed in to change notification settings - Fork 3
swap$
Subhajit Sahu edited this page Jun 12, 2020
·
12 revisions
Exchanges two values. 🏃 [:vhs:] 📦 🌔 📒
object.swap$(x, k, l);
// x: an object (updated)
// k: a key
// l: another key
// --> xconst object = require('extra-object');
var x = {a: 1, b: 2, c: 3, d: 4};
object.swap$(x, 'a', 'b');
// { a: 2, b: 1, c: 3, d: 4 }
x;
// { a: 2, b: 1, c: 3, d: 4 }
var x = {a: 1, b: 2, c: 3, d: 4};
object.swap$(x, 'a', 'd');
// { a: 4, b: 2, c: 3, d: 1 }