search

Home  >  Q&A  >  body text

JS 对象和数组的创建使用new和不使用new有什么区别呢?

比如:

var a = Array(); 和 var aa = new Array();
var b = Object(); 和 var bb  = new Object();


烟雨江南烟雨江南2862 days ago1140

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 00:49:55

    What is the difference between using new and not using new when creating JS objects and arrays? -PHP Chinese website Q&A-What is the difference between using new and not using new when creating JS objects and arrays? -PHP Chinese website Q&A

    Let’s take a look and learn.

    reply
    0
  • 迷茫

    迷茫2017-03-13 09:17:06

    使用new的话如果函数没有return会返回一个对象。不使用new如果函数没有return会返回undefined。

    reply
    0
  • Cancelreply