Home  >  Q&A  >  body text

创建数组里面的new什么意思啊?

看山看水看代码看山看水看代码2861 days ago2056

reply all(4)I'll reply

  • 钟毅

    钟毅2017-10-04 16:29:03

    NEW here refers to opening a space in the memory. Generally, NEW will open a default space in the extended memory. NEW An object opens a space based on the size of the object. After NEW, the variable stores the address of the newly opened space. Unlike variables that do not require NEW, only small variables can be placed. This is how to operate an object that requires a station pointer.

    reply
    0
  • 数据分析师

    数据分析师2017-09-30 22:44:43

    What does new mean when creating an array? -PHP Chinese website Q&A-What does new mean when creating an array? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • PHP中文网

    PHP中文网2016-12-17 13:29:36

    亲,这个没有区别,数组都是要在内存中开辟存储空间的

    创建js数组可以直接 var narr=['a','b','c'];
    个人感觉这种写法比较优雅,其他写法从来没用过,也不需要知道。

    js中的对象其实就是一个function xxx(),实例化的时候可以用new也可以不用, 直接xxx()这样调用就可以了


    js创建对象的三种方式:

        调用Object()函数

        var person=new Object();

        person.name="xxx",


       2. 采用Json形式创建对象

         var person={name:'xxx'}

       3.自定义函数函数形式创建对象

       function Person(name)

      {

           var obj=new Object();

           obj.name=name;

           return obj;
      }

    -------------------

    后两种不用new

    reply
    1
  • 阿神

    阿神2016-12-17 13:25:25

    创建一个新数组对象  

    Array()就是数组对象

    reply
    0
  • Cancelreply