Last active: 2 years ago
Swap variables in array
const arr = [
{
id: 0,
text: 'xfy',
},
{
id: 1,
text: 'dfy',
},
{
id: 2,
text: 'hello',
},
{
id: 3,
text: 'world',
},
];
[arr[0], arr[1]] = [arr[1], arr[0]]
console.log(arr)