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