zoukankan      html  css  js  c++  java
  • JS字符串的方法

    length 字符串的长度

    str.concat(str) 连接字符串,使用+运算符连接更简单
    str.charAt(index) 返回指定index的字符
    str.charCodeAt() 返回在指定的位置的字符的 Unicode 编码。
    str.indexOf(str,fromIndex) 返回指定字符首次出现的位置【从前向后搜索】
    str.lastIndexOf(str,fromIndex) 返回指定字符最后一次出现的位置【从后向前搜索】

    str.split() 把字符串分割为字符串数组。【split() 执行的操作与 Array.join 执行的操作是相反的。】

    str.slice(start,end) 指定开始位置和结束位置
    str.substring(start,end) 指定开始位置和结束位置
    str.substr(start,length) 指定子串的开始位置和长度

    【ECMAscript 没有对substr()进行标准化,因此反对使用它】
    【与 slice() 和 substr() 方法不同的是,substring() 不接受负的参数】
    【因此建议用slice()】


    toLocaleLowerCase() 把字符串转换为小写。
    toLocaleUpperCase() 把字符串转换为大写。
    toLowerCase() 把字符串转换为小写。
    toUpperCase() 把字符串转换为大写。

    isNaN(number) not a number 不是数字时返回true

  • 相关阅读:
    SpringCloud Gateway使用实例
    Nacos服务注册与发现
    HashMap源码分析——put方法
    Volatile关键字——内存可见性
    Java的JIT编译器
    why spring?
    mysql 锁
    sql server 表变量和临时表
    mysql 存储过程
    mysql 截取字符串
  • 原文地址:https://www.cnblogs.com/xingkongly/p/7577495.html
Copyright © 2011-2022 走看看