JavaScript - 分割代入の小ネタ2020.12.24に公開2021.03.25に更新1 min read読了の目安(約300字)JavaScripttech 前提 https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment 目的 MDN に記述されていなかった機能の紹介。 文字列の分割 const [ head, ...rest ] = 'abc' head // 'a' rest // [ 'b', 'c' ] 配列の添字で指定 const { 0: a, 2: b } = [ '00', '01', '02' ] a // '00' b // '02' end