我想到了如下的數組。我對JavaScript中多維數組的理解是否正確?
var array1D = []; // 1D Array
var array2D = [ [], ... ]; // 2D Array
var array3D = [ [ [], ... ], ... ]; // 3D Array
所以下面是所有2D數組的例子。
var x = [ [] ]; // 2D, not 1D!
var y = [ [], [] ]; // 2D, as expected
var z = [ [], [], [] ]; // 2D, not 3D!
同樣,下面是3D數組的所有示例。
var x = [ [ [] ] ]; // 3D, not 1D!
var y = [ [ [] ], [ [] ] ]; // 3D, not 2D!
var z = [ [ [] ], [ [] ], [ [] ] ]; // 3D, as expected
D表示數組的深度,而不是它有多少物品...... –
@NiettheDarkAbsol尼斯方式把它:) – Grateful
爲什麼有人會低估這一點?這個問題格式很好? – shash678