In js, use the object literal method to create an object, var obj={}; Since the Object constructor is not called, why is it still an instance? Shouldn't such an object be an empty object? Why is its prototype Object.prototype?
我想大声告诉你2017-05-19 10:26:47
var obj = {}; is just a shorthand, equivalent to var obj = Object.create({});
Object.create(null); may be an empty object.
淡淡烟草味2017-05-19 10:26:47
You have to ask about thisBrendan Eich
.
I think you should first tell me what you define as 空对象
.
According to your title description, I guess what you mean by 空对象
应该是指最原始的那个对象原型吧?这个东西是有的,它是null
should refer to the original object prototype, right? This thing exists, it is null
, and it is the end of the prototype chain of all objects.
我想大声告诉你2017-05-19 10:26:47
js has empty objects
Object.create(null);
Practice is the only criterion for verifying truth
大家讲道理2017-05-19 10:26:47
Conceptually speaking, Object is defined as the root object of all objects and is the most basic unit (reference) of the concept of "object-oriented". If it is removed, the entire concept will collapse;
Can you imagine matter without molecules/atoms?
No matter you create it with new or use literals, the compiler will automatically recognize the ancestor of the object
Yeah, null exception, this thing itself is a special case. js treats it as an object at the beginning, and then the so-called "empty object" phenomenon will appear in the subsequent Object.create(null). If it is defined at the beginning is a special value, then there is no such thing as Object.create(null). So in my understanding, this "empty object" is self-consistent and connected in definition, and should not be classified as "object-oriented" In this concept.