字符串
toUpperCase()
toLowerCase()
substring()
indefOf()
'str'.toUpperCase(); // "STR"
'STR'.toLowerCase(); // "str"
'hello world'.indexOf('world'); // 6
'hello world'.indexOf('w'); //6
'hello world'.substring(0,5) // "hello" 返回指定索引区间的子串:
数组
切片slice
var arr = ['a', 'b', 'c']
arr.slice(0, 1); // 'a' 'b'
arr.slice(-1); // 'c'
arr.slice(1); // 'b' 'c'
var arrCopy = arr.slice();
索引 indexOf
,索引从0开始,当一个元素不存在返回-1
var arr = ['a', 'b', 'c']
arr.indexOf('b'); // 1
arr.indexOf('inexistence') // -1