substring方法

xxx.substring()方法分为两种情况,括号中带的参数不一样,效果不同:

xxx.substring(0, 3) 表示取第一个到第三个字符,返回一个新的字符串(hello–>hel)

xxx.substring(3) 表示去掉前三个字符,返回一个新的字符串(hello–>lo)

substring方法_第1张图片
substring方法_第2张图片

你可能感兴趣的:(js)