码迷,mamicode.com
首页 > 编程语言 > 详细

javascript indexOf startWith

时间:2016-01-29 00:05:51      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:

    判断字符串是否以XX开头

    1.切割转换   var str = "ababaa",tags = jquery.trim(str);

    2. indexOf方法运行   !tags.indexOf("aba") == true, 说明 tags以“abc” 开头,否则不是以“abc”开头。

    3. 说明   indexOf()方法返回-1,0,>0的正数,而javascript number对象 等于0时能转换成false,其他值都只能转换成true;

       The indexOf() method returns the position of the first occurrence of a specified value in a string.

    If the Boolean object has no initial value, or if the passed value is one of the following:

       0, -0, null, "", false, undefined, NaN
       the object it is set to false. For any other value it is set to true (even with the string "false")!

       This method returns -1 if the value to search for never occurs.

javascript indexOf startWith

标签:

原文地址:http://www.cnblogs.com/rocky-fang/p/5167532.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!