调试输出数组时console.log(array)显示数组信息错误
发布于 6 年前 作者 naqian 19100 次浏览 来自 问答
function NewRandomPoint() {
   return {
      x: Math.random() * 100,
      y: Math.random() * 100
   }
}
 
var points = [
   NewRandomPoint(),
   NewRandomPoint(),
   NewRandomPoint()
]
 
console.log(points)

以上代码先生成了包含3个点的数组对象,然后用console.log()打印。

这是我的结果:

打印了两个元素并且显示该数组长度为2……

回到顶部