<!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

重学ES系列之字符串方面的处理的更多相关文章

  1. 重学ES系列之模版字符串

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. 重学ES系列之函数优化

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. 重学ES系列之新增的几个循环方法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 重学ES系列之拓展运算符

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. 重学ES系列之过滤数组

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 重学ES系列之Set实现数组去重、交集、并集、差集

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. 重学ES系列之新型数据结构Map应用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. 重学ES系列之变量的作用范围

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. 重学c#系列——字典(十一)

    前言 重学c#系列继续更新,简单看一下字典的源码. 看源码主要是解释一下江湖中的两个传言: 字典foreach 顺序是字典添加的顺序 字典删除元素后,字典顺序将会改变 正文 那么就从实例化开始看起,这 ...

随机推荐

  1. [已解决] error: cannot convert `int*' to `int**' for argument `2' to `void print_f(int, int**)'

    #include "stdio.h" #include "stdlib.h" #include "time.h" void print_f( ...

  2. 【课程汇总】OpenHarmony 成长计划知识赋能第二期课程(附链接)

    OpenHarmony 开源开发者成长计划第二期知识赋能直播课程以入门为主,共设置 8 节课,覆盖了应用开发.设备开发.内核驱动等多个技术领域.带领开发者快速了解如何玩转 OpenHarmony.如何 ...

  3. pt-osc又又出现死锁了

    今天使用pt-osc修改mysql表结构,又出现死锁了,老大让尽量解决这个问题,我们先分析一下pt-osc容易出现死锁的原因,再来解决这个问题. 根据pt-osc打印的日志,可以看到pt-osc执行原 ...

  4. defer综合

    A "defer" statement invokes a function whose execution is deferred to the moment the surro ...

  5. Java 字符串Split方法的一个坑

    java字符串的split,只传一个参数,后面空白的字符串会被忽略: public static void main(String[] args) { String str = "ab|c| ...

  6. 1.1 Qt Creater使用Python开发桌面软件的操作流程

    Qt Creater及Python的下载与安装过程不再赘述,读者可自行在网上搜索相应的下载与安装方法. 首先我们打开Qt Creater,单击"Create Project"按钮或 ...

  7. OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "ip": executable file not found in $PATH: unknown (Docker容器没有ip addr命令:exec ip addr 报错)

    一.报错 1.报错信息1: OCI runtime exec failed: exec failed: container_linux.go:380: starting container proce ...

  8. XCTF练习题---MISC---Get-the-key.txt

    XCTF练习题---MISC---Get-the-key.txt flag:SECCON{@]NL7n+-s75FrET]vU=7Z} 解题步骤: 1.观察题目,下载附件 2.拿到手以后直接惊呆,挺大 ...

  9. LINUX系统下安装PyCharm和annaconda3并配置

    以下是在ubantu18.04版本下的配置教程: Step 1 去PyCharm官网下载Linux版的PyChram安装压缩包 网址:https://www.jetbrains.com/zh-cn/p ...

  10. 106_Power Pivot之HR入离调转、在职、离职率相关指标

    博客:www.jiaopengzi.com 焦棚子的文章目录 请点击下载附件 一.背景 之前有帮公司HR做了些员工入离调转.在职.人工成本分析等(体量:4000人左右).在和其他朋友交流的时候得知,貌 ...