当前位置:网站首页>有意思的js 代码
有意思的js 代码
2022-04-23 07:01:00 【凌儿~】
有意思的js 代码
1.在字符串中查找某个字符所有的位置
```bash
(function sum (item){
var arr = 'indexhdfhsvfdgdindexbindex'
console.log(item,'item') //index item
var index = arr.indexOf(item)
console.log(index,'index') //0 index
var num = 0
while (index >= 0) {
num++
index = arr.indexOf(item, index + 1)
}
console.log('共出现'+num+'次') //共出现3次
})('index')
版权声明
本文为[凌儿~]所创,转载请带上原文链接,感谢
https://blog.csdn.net/rhcjqmm666/article/details/124254599
边栏推荐
- Planification du mouvement du manipulateur dans l'assemblage 3c
- Manipulator motion planning in 3C assembly
- Move layout (Flex layout, viewport label)
- Go语学习笔记 - 异常处理 | 从零开始Go语言
- [Effective Go 中文翻译]函数篇
- 青苹果影视系统源码 影视聚合 影视导航 影视点播网站源码
- Feign源码分析
- User manual of Chinese version of solidity ide Remix
- Guoji Beisheng openstack container cloud environment construction
- CTF attack and defense world brush questions 51-
猜你喜欢

Feign source code analysis

Intranet penetration series: icmptunnel of Intranet tunnel (Master James Barlow's)

Samsung, March to the west again

Cloud computing skills competition -- Part 2 of openstack private cloud environment

输入 “ net start mysql ”,出现 “ 发生系统错误 5。 拒绝访问 ” 。问题详解

Principle of sentinel integrating Nacos to update data dynamically

青苹果影视系统源码 影视聚合 影视导航 影视点播网站源码
![[极客大挑战 2019]Havefun1](/img/8b/b15bf31771d54db25f24d630e64093.png)
[极客大挑战 2019]Havefun1

三星,再次“西征”

Go语学习笔记 - 结构体 | 从零开始Go语言
随机推荐
Construction of middleman environment mitmproxy
每周leetcode - 06 数组专题 7~739~50~offer 62~26~189~9
干货!以点为形:可微分的泊松求解器
Go语学习笔记 - 结构体 | 从零开始Go语言
使用 Ingress 实现金丝雀发布
nn.Module类的讲解
Usage of databinding
Hump naming object
Research on system and software security (5)
一篇文章看懂变量提升(hoisting)
编译原理题-带答案
云计算技能大赛 -- openstack私有云环境 第二部分
[problem solving] vs2019 solves the problem that the EXE file generated by compilation cannot be opened
求3个字符串(每串不超过20个字符)中的最大者。
Go语学习笔记 - Slice、Map | 从零开始Go语言
CSV Column Extract列提取
Implementation of promise all
Intranet penetration series: icmptunnel of Intranet tunnel (Master James Barlow's)
Intranet penetration series: pingtunnel of Intranet tunnel
Buuctf misc brush questions