object literal object literal

"JavaScript Advanced Programming (3rd Edition)" There is a strange new word: object literal, can not understand. Looked at the English original, English is the object literal, or do not understand. Later I want to understand, largely literal word difficult to understand. It is what does that mean? When we speak, sometimes they use metaphors or metaphors, such as we say eagle wings to fly, generally refers not to the sky eagle in flight, usually to describe a person ambitious, but if the literal, it means, that is, literally, no metaphors. For example, male or said seat wings to fly, I'm not describing a portrait eagle fly freely, but the sky really have an eagle in flight, this is the literal meaning. As another example, I said that Dongfeng 41 in advance at supersonic speeds, this is not to describe it fast speed, but really supersonic, this is the literal meaning. But in Chinese, this argument seems to be rarely used, so it caused the "object literal" difficult to understand.

Object literal, the literal is displayed in accordance with those values, to define the object. If the conventional method of defining the object:

var person = new Object()

There are many ways then will default on Object will be automatically defined to person, which is equivalent to metaphor.

And if you use an object literal:

each person = {

  name: "Zhang Fei"

  age:40

}

It is based on the object out of the values ​​defined literally, so called "object literal" method.

 

Guess you like

Origin www.cnblogs.com/Sabre/p/11618872.html