object

  • Key value pair {key: value, key: value}
  • Object property name, not reference type (string, number, bool, variable value)
  • [“].
let obj = {
    name: 'AA'.age: 20.true: 1.undefined: null
};

let n = 100;
let obj1 = {};
obj1.name = "AA";  // {name: "AA"}, name is the attribute name (string)
obj1["age"] = 20;  // { name: "AA", age: 20 }
obj1.sex  // undefined

obj1[n] = 200;  // obj[100] = 200;

Keys returns an array containing all keys
Object.keys(obj1)  // ["name", "age"]

/ / delete
obj1.age = null;  // { name: "AA", age: null }
delete obj1.age;  // { name: "AA" }

// Objects, arrays
let n = { x: 100 };
let m = [100.200];
let obj = {};
obj[n] = 'AA';  // { '[object object]': 'AA' }
obj[m] = 'AA';  / / {' 100200 ':' AA '}
Copy the code

Qomolangma Training – 40 hours to thoroughly practice JavaScript basics P18, P19