This article mainly introduces how to access JavaScript class attributes. For more information, see
The code for accessing JavaScript class attributes is as follows: var fish = {head: 1, tail: 1, feature: {speak: false, swim: true} First, vertex OPERATOR: the Code is as follows: console. log (fish. head); // 1 console. log (fish. tail); // 1 console. log (fish. feature); // Object {head: 1, tail: 1, feature: Object} second, [] OPERATOR: Code: console. log (fish ['head']); // 1 note that the attribute name must be in the string format, for example, the Code is as follows: console. log (fish [head]); // error! Is the following code correct? The Code is as follows: for (var prop in fish) {console. log (fish [prop]);} the answer is yes, because the property of the traversal object exists in the string type, that is, the prop is 'head', 'tail ', 'feature '.