码迷,mamicode.com
首页 > 其他好文 > 详细

字符串

时间:2018-02-11 14:39:32      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:tin   搜索   www   aaa   last   ast   dex   blog   ring   

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‘

字符串

标签:tin   搜索   www   aaa   last   ast   dex   blog   ring   

原文地址:https://www.cnblogs.com/tflicong/p/8441049.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!