字符串原型方法

常见有34种(去除已经弃掉的方法):

  1. String.prototype.at()
  2. String.prototype.charAt()
  3. String.prototype.charCodeAt()
  4. String.prototype.codePointAt()
  5. String.prototype.concat()
  6. String.prototype.endsWith()
  7. String.prototype.includes()
  8. String.prototype.indexOf()
  9. String.prototype.isWellFormed()
  10. String.prototype.lastIndexOf()
  11. String.prototype.localeCompare()
  12. String.prototype.match()
  13. String.prototype.matchAll()
  14. String.prototype.normalize()
  15. String.prototype.padEnd()
  16. String.prototype.padStart()
  17. String.prototype.repeat()
  18. String.prototype.replace()
  19. String.prototype.replaceAll()
  20. String.prototype.search()
  21. String.prototype.slice()
  22. String.prototype.split()
  23. String.prototype.startsWith()
  24. String.prototype.substring()
  25. String.prototype.toLocaleLowerCase()
  26. String.prototype.toLocaleUpperCase()
  27. String.prototype.toLowerCase()
  28. String.prototype.toString()
  29. String.prototype.toUpperCase()
  30. String.prototype.toWellFormed()
  31. String.prototype.trim()
  32. String.prototype.trimEnd()
  33. String.prototype.trimStart()
  34. String.prototype.valueOf()

其他,String 类型自身属性:

  1. String.prototype[@@iterator]()
  2. String.raw({raw: [‘a’, ‘b’, ‘c’]})
  3. String.fromCharCode()
  4. String.fromCodePoint()

太多了,如何记住字符串方法?

4 + 8 + 16 + 6 = 34种

获取单个字符(4):

  • at()
  • charAt()
  • charCodeAt()
  • codePointAt() 返回 unicode 码位

查找(8):

  • startsWith()
  • endsWith()
  • includes() 区分大小写 数组同样也有
  • indexOf()
  • lastIndexOf()
  • match() 正则
  • matchAll()
  • search()

操作(16):

  • concat() 数组同样也有
  • padStart()
  • padEnd() 填充
  • repeat() 重复
  • replace() 原字符串不变
  • replaceAll() 原字符串不变
  • slice() 原字符串不变,数组有类似方法
  • split() 转换为数组
  • substring() 子串
  • toLocaleLowerCase() 小写
  • toLowerCase() 小写
  • toLocaleUpperCase()
  • toUpperCase()
  • trim() 原字符串不变
  • trimStart()
  • trimEnd()

其他(6):

  • isWellFormed() 是否包含单独代理项
  • toWellFormed()
  • localeCompare()
  • normalize()
  • toString()
  • valueOf() 返回字符串对象的值
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Fy哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值