What is the difference between `new Object()` and object literal notation?

前端 未结 11 742
北恋
北恋 2020-11-22 07:41

What is the difference between this constructor-based syntax for creating an object:

person = new Object()

...and this literal syntax:

11条回答
  •  有刺的猬
    2020-11-22 08:24

    Memory usage is different if you create 10 thousand instances. new Object() will only keep only one copy while {} will keep 10 thousand copies.

提交回复
热议问题