indexOf 返回字符串中指定字符首次出现的位置

  var str="hello, I am Miss bean!";

  str.indexOf("l")//结果为2

indexOf('l',2) //表示从第2位开始查找l元素首次出现的位置

 var str="hello, I am Miss bean!";
console.log(str.indexOf('l'));//结果2
console.log(str.indexOf('l',3));//结果3
console.log(str.indexOf('s'));//结果14
console.log(str.indexOf('s',15));//结果15

js字符串函数之indexOf()的更多相关文章

  1. js字符串函数(split、join、indexOf、substring)

    1,函数:split()功能:使用一个指定的分隔符把一个字符串分割存储到数组示例: str="jpg|bmp|gif|ico|png";arr= str .split(" ...

  2. js字符串函数

    JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串.var a = "hello";var b = ",world";var c = a ...

  3. 【repost】js字符串函数

    JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串.var a = "hello";var b = ",world";var c = a ...

  4. js字符串函数 [http://www.cnblogs.com/qfb620/archive/2011/07/28/2119799.html]

    JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串.var a = "hello";var b = ",world";var c = a ...

  5. 2018-06-20 js字符串函数

    str.length -> 字符串长度; str.indexOf() -> 从左边查找字符串中某字符的位置: str.lastIndexOf -> 从右边查找字符串中某字符的位置: ...

  6. js字符串函数之substring() substr()

    substring 方法用于提取字符串中介于两个指定下标之间的字符 substring(start,end) 开始和结束的位置,从零开始的索引 参数     描述start     必需.一个非负的整 ...

  7. js字符串函数之split()join()

    split方法用于把一个字符串切割成字符串数组,与join相反 一个参数表示以该参数为切割点, var str="silence's world"; console.log(str ...

  8. js执行js字符串函数的方法

    <script> var jsText = 'return function(){alert(1+1)}' var jscode = new Function(jsText)(); jsc ...

  9. js字符串操作函数

    js字符串函数 JS自带函数 concat 将两个或多个字符的文本组合起来,返回一个新的字符串. var a = "hello"; var b = ",world&quo ...

随机推荐

  1. SqlSever基础 Upper函数 返回字符串的大写形式

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  2. 11个让你吃惊的 Linux 终端命令

    原文:http://linux.about.com/od/commands/tp/11-Linux-Terminal-Commands-That-Will-Rock-Your-World.htm 作者 ...

  3. 关于跨域的ajax

    $.getJSON("http://query.yahooapis.com/v1/public/yql?callback=?", { q: "select * from ...

  4. nuget.exe the application could not be started

    http://stackoverflow.com/questions/5730412/error-when-running-the-nuget-exe-command Ok, so this turn ...

  5. Date Picker Calendar For Oracle Forms 6i

    Giving date picker calendar option to user for date type fields in Oracle Forms. I am providing you ...

  6. Servlet异常及其生命周期

    Servlet 异常 在javax.servlet包中定义了两个异常类 ServletException类 ServletException类定义了一个通用的异常,可以被init().service( ...

  7. (Theano 1)Theano自述文件

    Theano在GitHub上的自述文件 https://github.com/Theano/Theano 也不知道这个Theano好不好,但是从Theano到Lasagne:基于Python的深度学习 ...

  8. 9.Parameters

    1.Optional and Named Parameters calls these methods can optionally not specify some of the arguments ...

  9. 可以考虑使用SublimeText编辑器替代notepad++了

    大概是去年吧,这款编辑器神一般的出现在我面前,经过我小心翼翼的试用后发现并不是那么太顺手,插件配置都不太成熟,如Package Control. 最喜欢用它的zencoding还得专门开个小窗:ang ...

  10. Installing Python 3.5.2 from source

    Here are the procedures we are to follow, Download the source code of an official Python release. Co ...