js访问对象的属性
2021-04-24 20:27
标签:last def 访问 对象 nbsp person console bsp span js访问对象的属性 标签:last def 访问 对象 nbsp person console bsp span 原文地址:https://www.cnblogs.com/shun1015/p/12233069.htmlvar person = {
firstName: "Bill",
lastName: "Gates",
age: 50,
eyeColor: "blue"
}
console.log(person.firstName) //Bill
console.log(person[‘firstName‘]) //Bill
console.log(person.name) //二者打印的的是一样的
console.log(person[‘name‘]) //没有的时候都undefined