奇妙な問題があります。Javascriptを使用して多次元配列からいくつかの値を取得しようとしていますが、奇妙な出力が得られます。
これが私のコードです:
foo = [['3','4'],['5','6']];
for (bar in foo) {
baz = bar[0];
alert(baz);
qux = bar[1];
alert(qux);
}
上記の出力は次のとおりです。
// These are all alerts, by the way
0,undefined,1,undefined,$,f,$,c,e,a,c,l,c,l,i,i,n,a,s,l,i,c,o,a,p,g,e,g,e,i,n,c,o,e,r,e,m,f,l,p,i,h,e,r,g
誰かが何が起こっているのか教えてもらえますか?
これが問題のjsFiddleです:http://jsfiddle.net/Jey6w/
編集:
これが別のjsFiddleで、「インセプション」の別のレイヤーがあります:http: //jsfiddle.net/8vyGq/
出力:
// Again, these are all alerts, and * signifies undefined
0**1**$ff$ceaacllcllinnassliicooappgeegeeinncooerremmfllpiiheergg