SOURCE

//声明一个 set,可以是对象和数组
let s = new Set();

let s2 = new Set(['1','2','3']);

//元素个数 size
console.log(s2.size);

  //添加新的元素
  s2.add('4');

  //删除元素
  s2.delete('1');

    //检测
    console.log(s2.has('3'));

 //清空
// s2.clear();

 //遍历
 for(let v of s2){
     console.log(v);
 }
        //...提取
        let arr = [1,2,3,4,5,4,3,2,1];
        //1. 数组去重
        let result = [...new Set(arr)];
        
        //2. 交集,.1 先去重,然后对比arr2里有没有arr的item,提取交集
        let arr2 = [4,5,6,5,6];

        let s3 = [...new Set(arr)].filter( item =>{new Set(arr2).has(item) })

         //3. 并集
         let union = [...new Set([...arr, ...arr2])];

          //4. 差集

          let s4 = [...new Set(arr)].filter( item => !new Set(arr2).has(item) )

          console.log(s4);

          //Map 键值对

           //声明 Map

           let m = new Map();

            //添加元素
            m.set('name','feizhu');
            m.set('change',function(){
                console.log('改变你');
            })
            let key = {
                school:'feizhuxueyuan'
            };

            m.set(key,['BJ','GZ']);

             //size
        // console.log(m.size);

        //删除
        // m.delete('name');

        //获取
        // console.log(m.get('change'));
        // console.log(m.get(key));

        //清空
        // m.clear();

        //遍历
        for(let v of m){
            console.log(v);
        }

        function phone(brand,price){
            this.brand = brand;
            this.price = price;

        }

        //添加方法
        phone.prototype.call = function(){
            console.log('打电话')
        }

        //实例化对象

        let huawei = new phone('huawei','1999');
            huawei.call();
            console.log(huawei);

            //class 类

            class shouji {
                constructor(brand,price){
                    this.brand = brand;
                    this.price = price;
                }

                 //class添加方法

                 call(){
                      console.log('接电话');
                 }
            }

           let chuizi = new shouji('chuizi','2499');

            //class 静态属性
            class Phone{
            //静态属性
            static name = '手机';
            static change(){
                console.log("我可以改变世界");
            }
        }

        //class 继承

        class earphone {
             //构造方法
                constructor(brand,price){
                    this.brand = brand;
                    this.price = price;
                }

                 //父类的成员属性

                 call(){
                      console.log('接电话');
                 }
            }

            class airpod extends earphone{
                //构造方法
                  constructor(brand,price,color){
                    //继承父级的方法
                    super(brand,price);
                    this.color = color;
                }
            //添加方法
            photo(){
                console.log('拍照');
            }
          
                 call(){
                console.log('我可以进行视频通话');

            }

            }

            const apple = new airpod('apple','2000','white');
             apple.call();
             apple.photo();

             //1. Object.is 判断两个值是否完全相等 
             const a = 1;
             const b = 2;
             console.log(Object.is(a,b))

            //2. Object.assign 对象的合并,相同的会覆盖,不相同则合并
        const config1 = {
            host: 'localhost',
         port: 3306,
          name: 'root',
             pass: 'root',
            test: 'test'
         };
         const config2 = {
            host: 'http://atguigu.com',
             port: 33060,
            name: 'atguigu.com',
            pass: 'iloveyou',
            test2: 'test2'
         }
        console.log(Object.assign(config1,config2));

        //3. Object.setPrototypeOf 设置原型对象  Object.getPrototypeof

        const school ={
            name:'feizhu'
        }

        const cities ={
            xiaoqu:['zhuhai','huadou']

        }

        //设置原型对象

        Object.setPrototypeOf(school,cities);
        console.log(Object.getPrototypeOf(school));
         console.log(school);
console 命令行工具 X clear

                    
>
console