Skip to content

Latest commit

 

History

History
39 lines (21 loc) · 683 Bytes

File metadata and controls

39 lines (21 loc) · 683 Bytes

字符串内置方法

toUpperCase

toUpperCase()把字符串转换为大写

var s = 'abcd';
console.log(s); // 'ABCD'

toLowerCase

toLowerCase()把字符串转换为小写

var s = 'ABCD';
console.log(s); // 'abcd'

indexOf

indexOf()找出指定字符串出现的位置

var s = 'abcdef1234abcdef';
console.log(s.indexOf('1234'));

substring

substring(idxStart, [idxEnd])返回指定索引区中的子串

var s = 'abcdefg';
console.log(s.substring(1,5));

substr

substr(start, [length])返回指定索引位置后指定长度的字串

var s = 'abcdefg';
console.log(s.substr(1,5));