Object.create ({}): Is this a good practice?

I talked to some professionals who work with JavaScript in the company, and I was told that it is not good practice to instantiate an object using newwithout using a global object {}, even if I want an empty object, for example:

var wrong1 = new Object();
var wrong2 = {};

But the most correct way in accordance with them and company standards is to create it as follows:

var correct = Object.create({});

Passing an empty object as a prototype of an empty object seems pretty reworked and possibly even aimless.

Can someone give me an answer to the question why this is recommended, and if not, why? (possible pros and cons)

+4
source share
1 answer

.

Object.prototype -> {}

, .

, Object.create({}) .

Object.prototype -> {} -> {}

() {}, , , Object.prototype.

Object.create - , , new. , {} .

, - , ( ) " ".

, , , {} / , Object, .

var Object = 3;
// ...
Object.create({}) // TypeError: Object.create is not a function(...)

, , Object, , {} , , , .

+6

All Articles