One: literal meaning
Literal means how to express this value, generally dropping an expression, and assigning a value to a variable, the right side of the equal sign can be considered literal.
The literal amount is divided into string literal quantities (string literal), array literal quantities (array literal), and
Object literal, and also a function literal (literal).
Example:
var test= "Hello world!";
"Hello world!" Is the string literal, and test is the variable name.
Two: Object literal quantity
There are two ways to access an object literal: the example below,
var obj = {
A: ' AAA ',//a is attribute, ' AAA ' is attribute value
B: ' BBB ',
C: ' CCC '
}
Method One: obj.a//aaa,for in Traversal object, this method is invalid ...
Method Two: obj[' A ']//aaa, must be quoted
"The point method only fits the case where the property is a string, and if the property is a variable, only the latter"
When a property is a variable, you can only assign values in the following ways:
var obj = {};
obj[$a] = ' value ';
If you write {$a: ' value '} directly, $a will be parsed into a string.
Three: usage of keyword in
Format: (variable in object) ... Attention
When object is an array, "variable" refers to the "index" of arrays;
When object is an object, variable refers to the object's properties.
The above article on the literal volume of JS, object literal access, keyword in the use of small parts to share all the content, I hope to give you a reference, but also hope that we support the cloud habitat community.