当前位置:网站首页>有意思的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
边栏推荐
- Go语学习笔记 - 语言接口 | 从零开始Go语言
- 云计算技能大赛 -- openstack私有云环境 第一部分
- C 输出一种二维数组,特点如下。
- sql 使用过的查询语句
- Positioning of high precision welding manipulator
- 1216_MISRA_C规范学习笔记_控制流的规则要求
- 惨了,搞坏了领导的机密文件,吐血分享备份文件的代码技巧
- Interview learning route
- Intranet penetration series: pingtunnel of Intranet tunnel
- Compiling principle questions - with answers
猜你喜欢
Attack and defense world misc questions 1-50
Intranet penetration series: ICMP of Intranet tunnel_ Tran
Data security has become a hidden danger. Let's see how vivo can make "user data" armor again
如何在SQL Server中导入excel数据,2019版
Canvas learning Chapter 1
yum源仓库本地搭建的两种方法
The whole house intelligence bet by the giant is driving the "self revolution" of Hisense, Huawei and Xiaomi
智能名片小程序名片详情页功能实现关键代码
upload-labs 靶场练习
Thinkphp6 + JWT realizes login verification
随机推荐
以下程序实现从字符串str中删除第i个字符开始的连续n个字
[go] common concurrency model [generic version]
求3个字符串(每串不超过20个字符)中的最大者。
MySQL——第一章节(MySQL中的数据类型)
利用sqlmap注入获取网址管理员账号密码
Summary of facial classics
Compiling principle questions - with answers
Implementation of promise all
[untitled]
DVWA靶场练习
feign如何集成hystrix
Go语学习笔记 - Slice、Map | 从零开始Go语言
Depth of binary tree
1+x云计算中级--脚本搭建读写分离
1216_MISRA_C规范学习笔记_控制流的规则要求
[极客大挑战 2019]Havefun1
雲計算技能大賽 -- openstack私有雲環境 第一部分
Planification du mouvement du manipulateur dans l'assemblage 3c
巨头押注的全屋智能,正在驱动海信、华为、小米们「自我革命」
MySQL -- the secret of lock -- how to lock data