记得开心=。=|

ES6字符串API

ES6 字符串API

以下均为字符串的实例(原型)方法

  • includes

判断字符串中是否包含指定的子字符串

  • startsWith

判断字符串中是否以指定的字符串开始

  • endsWith

判断字符串中是否以指定的字符串结尾

  • repeat

将字符串重复指定的次数,然后返回一个新字符串。

const text = "成哥是狠人";


console.log("是否包含“狠”:", text.includes("狠"));
console.log("是否以“成哥”开头:", text.startsWith("成哥"));
console.log("是否以“狠人”结尾:", text.endsWith("狠人"));
console.log("重复4次:", text.repeat(4));

本文作者:HuangBingQuan

本文链接:https://www.cnblogs.com/bingquan1/p/17383193.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   HuangBingQuan  阅读(14)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 不将就 码农权
  2. 2 Bleeding Love 码农权
  3. 3 想你念你 码农权
Bleeding Love - 码农权
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

Not available