2020
09-28
09-28
JavaScript面试中常考的字符串操作方法大全(包含ES6)
一、charAt()返回在指定位置的字符。varstr="abc"console.log(str.charAt(0))//a二、charCodeAt()返回在指定的位置的字符的Unicode编码。varstr="abc"console.log(str.charCodeAt(1))//98三、concat()连接字符串。vara="abc";varb="def";varc=a.concat(b);console.log(c);//abcdef四、indexOf()检索字符串。indexOf()方法对大小写敏感!varstr="Helloworld!"console.log(str.indexOf("Hello"))//0console.log(st...
继续阅读 >