Creating JS object with Object.create(null)?

前端 未结 5 513
不知归路
不知归路 2020-11-28 01:58

I know a lot of ways to create JS objects but I didn\'t know the Object.create(null)\'s one.

Question:

is it exactly the same as:

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 02:22

    Creating objects by using {} will create an object whose prototype is Object.prototype which inherits the basic functions from Object prototype while creating objects by using Object.create(null) will create an empty object whose prototype is null.

提交回复
热议问题