js ES7 两个重要新特性

1.Array.prototype.includes

用来判断数组是否含有某个元素

        // Array.prototype.includes
        const mingzhu = ["西游记","红楼梦","三国演义","水浒传"];
        //判断
        console.log(mingzhu.includes('西游记'));//true
        console.log(mingzhu.includes("史记"));//false

        const arr = [1,2,3,4,5];
        console.log(arr.includes(5));//true
        console.log(arr.includes(6));//false

 

2.**运算符实现幂运算

        //**
        console.log(2 ** 10);//1024
        console.log(Math.pow(2,10));//1024

 

posted @ 2021-09-26 22:17  jerryfish  阅读(219)  评论(0编辑  收藏  举报