部分场景下还是能用到的,比如游戏
var str = 'To be, or not to be, that is the question.'; var count = 0; var pos = str.indexOf('e'); while (pos !== -1) { count++; pos = str.indexOf('e', pos + 1); } console.log(count) //4
扫一扫分享
404
帖子
30
小组
2177
积分
发帖
回复
分享