JS Object的用法
读取属性的方法记一下
//js object的写法 const person = { firstName: "John", lastName: "Doe", age: 50, eyeColor: "blue", fullName: function () { return this.firstName + " " + this.lastName; } }; //获取object的属性方法 //法一: console.log("法一:",person.firstName); //法二: console.log("法二:",person["firstName"]);
本文来自博客园,转载请注明原文链接:https://www.cnblogs.com/keeplearningandsharing/p/18361544