干掉字符串两端的空格
const str = ' 1234 '
let res = str.trim()
字符串长度
const str = '1234'
let res = str.length
获取指定位置的字符串
const str = 'abcd'
let res = str.charAt(1)
ASCLL对应的值
const str = String.fromCharCode(65)
拼接字符串
const a = '123'
const b = '456'
const c = a.concat(b)
获取某个字符串所在的索引值
const str = 'abc'
let res = str.indexOf('a')
从后向前找某个字符串的索引值
const str = 'abc'
let res = str.lastIndexOf('a')
替换字符串
const str = 'abc,def'
const res = str.replace(',','')
提取字符串
const str = 'abcdef'
const res = str.slice(2,5) || str.substring(2,5)
截取字符串
const str = 'abcdef'
const res = str.substr(2,3)
切割字符串为数组
const str = 'abc,def'
const res = str.split(',')
字符串转小写
const str = 'ABC'
const res = str.toLocaleLowerCase() || str.toLowerCase()
字符串转大写
const str = 'abc'
const res = str.toLocaleUpperCase() || str.toUpperCase()