字符串

var str = '百度搜索-WWW.baidu.com';

str.charAt(1);     // '度'
str.charCodeAt(1);   // 24230
String.fromCharCode(24230, 25628);   // '百度'

str.indexOf('b', 3);      // 4  indexof(' ',从第几位开始)从左往右
str.lastIndexOf('o');       // 从右往左

'1000' < '2'   // true
'1000' > 2   // true

str.substring(0, 4);    // '百度搜索'
str.slice(-3);        // 'com'

str.toUpperCase();   // '百度搜索-WWW.BAIDU.COM'
str.toLowerCase();   // '百度搜索-www.baidu.com'

str.split('.', 2);     // [ '百度搜索-WWW', 'baidu' ]

var arr = [ 'www', 'baidu', 'com' ];
arr.join('aaa');      // 'www.baidu.com'

posted @ 2018-02-11 12:36  hey-李高冷  阅读(117)  评论(0编辑  收藏  举报