charAt()从一个字符串中返回指定的字符
let str="hesr ase"
console.log(str.charAt(3)) //r
charCodeAt()返回指定位置的字符的编码
let str="asdf sdfw"
console.log(str.charCodeAt(2)) //100
endsWith()判断字符串是否是以指定的子字符串结尾(区分大小写)
let str='cds Sfe jdkJ'
console.log(str.endsWith('jdkj')) //false
console.log(str.endsWith('jdkJ')) //true
repeat()复制该字符串并连接起来,构成一个新的字符串
let str='asd'
console.log(str.repeat(3)) //asdasdasd
slice()提取字符串中的一部分,并返回新的字符串
let str='asd chf se'
console.log(str.slice(2,5)) //d c
console.log(str.slice(4)) //chf se
console.log(str.slice(-2)) //se
startsWith()判断当前字符串是否以给定子字符串开头,如果是,则返回true,否则返回false(区分大小写)
let str='sde adfe jsk'
console.log(str.startsWith('sde')) //true
console.log(str.startsWith('sde',3)) //false 3:开始的位置
console.log(str.startsWith('Sde')) //false
substring()截取字符串开始索引到结束索引之间的集合
let str="asdf djgs kxl"
console.log(str.substring(2,5)) //df
toLowerCase()将字符串值转为小写形式,并返回
let str='JKDSER jKDjkdf sdfJSD'
console.log(str.toLowerCase()) //jkdser jkdjkdf sdfjsd
toUpperCase()将字符串值转为大写形式,并返回
let str='sdg S djKLJ'
console.log(str.toUpperCase()) //SDG S DJKLJ
trim()将字符串的两端清除空格,并返回新的字符串,不修改原来字符串
let str=' hello world! '
console.log(str.trim()) //hello world!