<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
//es6直接写入变量和函数,作为对象的属性和方法
// const name = 'walter',age = 20;
// const person = {
// name,
// age,
// sayName(){
// console.log(this.name)
// }
// }
// person.sayName()
//
// function fn(x,y) {
// return {x,y}
// }
// console.log(fn(10,20))//x: 10 y: 20
//直接写入变量和函数,设置和获取选择器
// let cart = {
// wheel:4,
// set(newVal){
// if (newVal < this.wheel){
// throw new Error('轮子数太少了')
// }
// this.wheel = newVal;
// },
// get(){
// return this.wheel;
// }
// }
// cart.set(6)
const obj = {};
obj.isShow = true;
const name = 'a';
obj[name+'bc'] = 123;
console.log(obj);
//对象的方法
//is() === 比较两个值是否严格相等
console.log(Object.is(NaN,NaN))//true
//assign() 对象的合并 Object.assign(新对象,被合并对象1,被合并对象2)
let newObj = Object.assign({},{a:1},{b:2})
console.log(newObj)//{a: 1, b: 2}
</script>
</body>
</html>