ES2015(ES6)の分割代入でCannot set property of undefinedやis not definedというエラーがでる | Black Everyday Company

AとBの値を入れ替えるときに分割代入(Destructuring assignment)構文をつかうと、テンポラリ変数を使わなくてすむ。ということで、配列の中身をシャッフルする関数を書いているときに、分割代入構文を使ったのだが、「Cannot set property 'hoge' of undefined」や前の処理で定義したはずの変数が「'hoge' is not define…