1.一个字符串可以使用单引号或双引号

2.查找

字符串使用 indexOf() 来定位字符串中某一个指定的字符首次出现的位置

如果没找到对应的字符函数返回-1

lastIndexOf() 方法在字符串末尾开始查找字符串出现的位置。

3.length长度

4.内容匹配

match()函数用来查找字符串中特定的字符,并且如果找到的话,则返回这个字符。

5.替换内容

replace("","") 方法在字符串中用某些字符替换另一些字符。

6.字符串大小写转换

字符串大小写转换使用函数 toUpperCase() / toLowerCase()

7.字符串转为数组

字符串使用split()函数转为数组:

txt="a,b,c,d,e"   // String
txt.split(",");   // 使用逗号分隔

8.常用字符串属性和方法

属性:

  • length
  • prototype
  • constructor

方法:

  • charAt()
  • charCodeAt()
  • concat()
  • fromCharCode()
  • indexOf()
  • lastIndexOf()
  • match()
  • replace()
  • search()
  • slice()
  • split()
  • substr()
  • substring()
  • toLowerCase()
  • toUpperCase()
  • valueOf()

js-String的更多相关文章

  1. Right in the Center (js string algorithm)

    Right in the Center (js string algorithm) codewars https://www.codewars.com/kata/5f5da7a415fbdc0001a ...

  2. 说说 js String

    首先说说js的字符串,说到字符串这个就和我们原来的C# 代码有区别的就是,js里面没有chart类型.就是说他里面的 “ ”和‘ ’是要表达一样的意思. 其实这个里面就有一个问题了特别实在拼接字符串的 ...

  3. js string to int

    一.js中string转int有两种方式 Number() 和 parseInt() <script>     var   str='1250' ;  alert( Number(str) ...

  4. js string和number

    number Js只有一种数字类型(包括整型,浮点型) 极大或极小的可用科学计数法来表示.(7.7123e+1) 所有js数字均为64位 Js所有的数字都存储为浮点型 小数的最大位数是17位 0开头的 ...

  5. js String对象

    字符串(String) 字符串(String)使用长度属性length来计算字符串的长度: 在字符串中查找字符串 字符串使用 indexOf() 来定位字符串中某一个指定的字符首次出现的位置: 实例 ...

  6. js String对象中常用方法小结(字符串操作)

    1.charCodeAt方法返回一个整数,代表指定位置字符的Unicode编码. strObj.charCodeAt(index) 说明: index将被处理字符的从零开始计数的编号.有效值为0到字符 ...

  7. javascript js string.Format()收集

    方案1http://www.cnblogs.com/loogn/archive/2011/06/20/2085165.html String.prototype.format = function(a ...

  8. js String方法集合

    //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String//返回对应索引的字符 ...

  9. js String Trim函数

    <javascript> String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,"& ...

  10. js string 转 int 注意的问题——parseInt

    < script > var str = '1250';alert(Number(str)); //得到1250 alert(parseInt(str)); //得到1250 var st ...

随机推荐

  1. .net简单页面后台绑定下拉框,按钮,分页 后台cs文件

    二.cs文件 using System;using System.Collections.Generic;using System.Web.UI;using System.Web.UI.WebCont ...

  2. 【Solr初探】Solr安装,启动,查询,索引

    1. 安装&启动 官网:http://lucene.apache.org/solr/ 下载源代码,解压,进入根目录(我把solr放在/usr/local/solr下) 在/usr/local/ ...

  3. 从字节理解Unicode(UTF8/UTF16)

    如果你不知道或者不了解什么是Unicode/UTF8/UTF16,请详细阅读这篇文章(这也是这篇博文的先决条件): 学点编码知识又不会死:Unicode的流言终结者和编码大揭秘 但是如果你看完以上文章 ...

  4. js 计算两个日期之间的周数

    //返回两个日期相差的周数 function WeeksBetw(date1, date2) { //这里的date1,date2都是Date对象 var d1 = new Date(date1); ...

  5. Fedora下YouCompleteMe配置

    需要在默认的.ycm_extra_conf.py 中添加(C++的路径可能需要根据版本号修改) '-isystem', '/usr/include', '-isystem', '/usr/includ ...

  6. Tornado模块分类和各模块之间的关系

    1. Core web framework tornado.web — 包含web框架的大部分主要功能,包含RequestHandler和Application两个重要的类 tornado.https ...

  7. 异常处理:你不可能总是对的 - 零基础入门学习Python032

    异常处理:你不可能总是对的 让编程改变世界 Change the world by program 因为我们是人,不是神,所以我们经常会犯错.当然程序员也不例外,就算是经验丰富的码农,也不能保证写出来 ...

  8. C语言--位运算符

    一.位运算符 1.按位与:& 1> 功能 * 只有对应的两个二进制位为1时,结果位才为1,否则为0 * 举例:10用二进制表示为1010,  7用二进制表示为0111.对两个数值进行&a ...

  9. LeetCode_Rotate Image

    You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...

  10. IC封装图片认识(二):TO封装图

    TO-18 TO-220 TO-247 TO-264 TO-52 TO-71 TO-72 TO-78 TO-8 TO-92 TO-93 TO-99 TO-263&268 FTO-220 ITO ...