JavaScript学习笔记07--objects
1. objects定义
const myObj = {
myName: "yuxian",
age: 21,
}
console.log(myObj);
2.Objects操作函数
2.1 直接取出元素
const myObj = {
myName: "yuxian",
age: 21,
}
console.log(myObj);
console.log(myObj.myName);//方法1
console.log(myObj['myName']);//方法2,可以根据用户输入来选择objs类的元素
2.3 添加元素
const myObj = {
myName: "yuxian",
age: 21,
}
myObj.location = 'anhui';
console.log(myObj);