ES6 String Array

176 阅读1分钟
<script>
    //ES6 String AND Array

    //String
    // String.prototype.charAt(num) charCodeAt slice(start = 0  end = this.length)
    //indexOf(str,start = 0) 起始索引 -1; split(',') 按照规则拆分; join(',') 
    //toUpperCase toLowerCase  
    // let str = 'weicome to here!';
    // console.log(str.charAt(3) === str[3]);
    // console.log(str.charCodeAt(1));

    // ES6 String
    //字符串匹配 indexOf

    // String.prototype.isInclude = function(str) {
    //     if (this.indexOf !== -1) {
    //         return true
    //     } else {
    //         return false
    //     }
    // }
    // console.log("1233".isInclude('12'));
    // let str = 'if you love it,du not love he and she!'
    // console.log(str.includes('it', 1));
    // startsWidth('w',2) endWidth('w',5) 以什么开始
    //前后缀比较
    //repeat
    //产生由10个*组成的字符串。
    // let str = '*'.repeat(10);

    //模板字符串
    //`[] love []`
    // let name1 = 'I';
    // let name2 = 'You';
    // let str = `${name1} love ${name2}`

    //字符串的换行 
    // let str = `
    // <div>
    //     <span>${1}</span>
    // </div>
    // `
    // ${} 原始值 引用值
    // {} =》[object object] [1,2,3] =》 1,2,3 toString
    //表达式 函数
    //优点 
    //更标准的字符串,更高的处理字符串拼接问题
    //语义化更好
    //防止注入 XSS

    //字面量 var arr = [];
    // var arr = new Array(9)
    // var arr = new Array.of(9)
    //Array.from 
    
</script>