这在我编写的其他脚本中有效,但在这里不行。为什么? 我编写的其他脚本已经能够显示整个数组, 并能够显示 1-2-3 级深度。 即原始[0]/原始[0][0] 我错过了一些非常简单的事情吗?
获胜答案在这里: How can I create a two dimensional array in JavaScript? 工作正常吗?
<html>
<head>
<script>
Original = [
[1,2,3,4,5,6,7,8,9,0],
[0,9,8,7,6,5,4,3,2,1],
[q,w,e,r,t,y,u,i,o,p],
[a,b,c,d,e,f,g,h,i,j],
];
function TestFunction(){
alert(Original);
}
</script>
</head>
<body>
<button onClick = TestFunction()>Test</button>
</body>
</html>
最佳答案
问题是你有一堆未声明的变量。在数组中,字符串必须用引号引起来。
Original = [
[1,2,3,4,5,6,7,8,9,0],
[0,9,8,7,6,5,4,3,2,1],
['q','w','e','r','t','y','u','i','o','p'],
['a','b','c','d','e','f','g','h','i','j'],
];
这是更新的 fiddle
关于javascript - 在警告框中显示数组内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33089461/