1. is the object literally a json-type object? 2. suppose there is a json type object, such as vara {}; 3. what is the difference between the following operations on json? ①. propertyAvalueA; ② vara {propertyA: valueA}; is an internal external attribute definition method 1. object literal = json type object?
2. assume there is a json-type object, such as var a = {};
3. What are the differences between json operations in the following ways:
① A. propertyA = valueA;
② Var a = {propertyA: valueA };
Is a way to define an internal external attribute.
Reply content:
1. is the object literal === json type object?
2. assume there is a json-type object, such as var a = {};
3. What are the differences between json operations in the following ways:
① A. propertyA = valueA;
② Var a = {propertyA: valueA };
Is a way to define an internal external attribute.
1. the object belongs to the reference type, ===, not true;
2. a. propertA = valueA and a = {propertyA: valueA}; no difference. However, it should be noted that there is a difference between var a = function () {}; a. prototype. propertyA = valueA and a. prototype = {propertyA: valueA.
The JSON type object does not exist.var obj = {};
It is called the object literal. JSON and XML are a set of syntax formats.
a={propertyA:valueA};
Is to assign a value directly to the literal,a.propertyA=valueA
Ora[propertyA]=valueA
Can be used to access/modify/add literal attribute values. (When using the vertex operator, propertyA must be a legal JavaScript identifier)
1. the object literal volume refers to the definition of the object using the key/value method, which is simple and clear and has no limit on the value.json
The value can only be: number (integer or floating point number), string (in double quotation marks), logical value (true
Orfalse
), Array (in square brackets), object (in curly brackets ),null
. That is to sayjson
The value cannot be a function. So there is a difference between the two.
2,a.propertyA = valueA;
It is equivalent to adding an attribute to an object, and the previously defined attribute still exists. Whilea = {propertyA: valueA};
Yesa
Overwrite, that is, beforea
Has been overwritten.a
OnlypropertyA
This attribute.