---
# System prepended metadata

title: ES6 - Swap
tags: [ES6]

---

---
title: ES6 - Swap
tags: ES6
---

# 首PO!! ES6 Swap

    
最近剛學到的簡單swap方法

let arr = [1, 2, 3, 4];

[arr[0], arr[1]] = [arr[1], arr[0]];

console.log(arr); *//[2, 1, 3, 4]*