LoginSignup
0
0

More than 3 years have passed since last update.

【JavaScript】配列の要素を一行で入れ替える

Posted at

配列の要素を一行で入れ替える方法

const swap = (arr, bef, af) => { 
    arr[bef] = [arr[af], arr[af] = arr[bef]][0];
}

参考というより引用:http://beatdjam.hatenablog.com/entry/2017/09/24/025854

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0