JS two ways to access the object's properties

var person = {
    name: "nick"
};

console.log(person["name"]); // "nick";
console.log(person.name); // "nick";

Advantages and disadvantages of the two methods: by method brackets variable attributes of access to the object, and may not represent the point method;

Brackets law must double quotes can be any string;

Guess you like

Origin www.cnblogs.com/cloudbarrychen/p/11316843.html