<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>字符串方面的处理</title>
</head>
<body> </body>
<script>
let str = 'maomin';
console.log(str.indexOf('x')); //-1
console.log(str.includes('x')); //false
// includes 是indexOf的升级版,如果不存在字符直接返回false。
console.log(str.startsWith('m')); //true
console.log(str.endsWith('n')); //true
// startsWith 是查找以什么开头的字符。endsWith则是查找以什么结尾的字符。
console.log(str.startsWith('a',1)); //true
console.log(str.endsWith('o',3)); // true,前三个字符‘mao’当中是以o结尾的。
// 都可以传参数,但是不一样的是。startsWith是以索引0开头查找。而endsWith是以索引1开头查找。
</script>
</html>

更多内容请见原文,原文转载自:https://blog.csdn.net/weixin_44519496/article/details/119862167

最新文章

  1. 2014年---移动端webapp个人年度总结
  2. web前端基础知识总结
  3. git提交远程仓库命令
  4. android应用锁之获取前台进程包名方法
  5. Sqlite数据库 找不到请求的 .Net Framework Data Provider。可能没有安装
  6. MyEclipse 2014GA 新建 Web Project 并配置 SSH
  7. IE 中创建 子窗口 传值 与接收值 【window.showModalDialog】
  8. 修改Hadoop作业调度算法过程解析
  9. win32内核程序中进程的pid,handle,eprocess之间相互转换的方法
  10. cortexm内核 栈的8字节对齐及关键字PRESERVE8
  11. HDU5723 Abandoned country (最小生成树+深搜回溯法)
  12. .Net Core实践1
  13. MySQL 8.0.12 基于Windows 安装教程(超级详细)
  14. linux下ping不通问题的说明与解决(DNS配置丢失)
  15. 【poj1741】Tree 树的点分治
  16. python中类的创建和实例化
  17. python基础教程 变量/输入输出/if判断
  18. js 遍历行和列
  19. 【Linux技术】linux库文件编写&#183;入门
  20. USB学习笔记连载(十一):CY7C68013A的启动方式-EEPROM

热门文章

  1. Java 8 学习记录
  2. Java学习day37
  3. TypeScript学习_入门向
  4. C#接入SMTP邮件服务
  5. 分享两个实用的shell脚本
  6. Java-GUI 编程之 Swing
  7. Linux内存、Swap、Cache、Buffer详细解析
  8. 评估海外pop点网络质量,批量探测到整个国家运营商ip地址段时延
  9. 性能测试:tcpcopy
  10. MySQL体系结构与数据类型