ES6 4个方法

var string = 'Yo'

string.startsWith('Y')        -> true      startsWith()查找字符串是否是以某一个字段开始的

string.startsWith('o‘)        -> false

string.endsWith('o')         ->true        endsWith()查找字符串是否是以某一个字段结束的

string.endsWith('Y')         ->false

string.repeat(3)                ->'YoYoYo'      字符串repeat重复3次

string.indexOf('Y')          -> 0              indexOf()查找字符串是否有该字符

string.includes('Y')         ->true           includes()查找字符串是否有该字符

原文地址:https://www.cnblogs.com/gqx-html/p/9203456.html