zoukankan      html  css  js  c++  java
  • JavaScript String常用方法和属性

      在JavaScript中,字符串是不可变的,如果使用索引对字符串进行修改浏览器不会报错,但也没有任何效果。JavaScript提供的这些方法不会修改原有字符串的内容,而是返回一个新的期望的字符串。

     一、string中的常用属性

     1. length

    说明:

      字符串的长度属性,一直保持跟踪着该字符串中包含的字符数。

     二、string中的常用方法

     1. toLowerCase() 和 toUpperCase()

    说明:

      toLowerCase(): returns a copy of the string with its letters converted to lowercase. Numbers, symbols, and other characters are not affected.

      toUpperCase(): returns a copy of the string with its letters converted to capitals. Numbers, symbols, and other characters are not affected.

     2. trim()

    说明:

      returns a copy of the string with beginning and ending whitespace characters removed.

  • 相关阅读:
    【HDOJ】1224 Free DIY Tour
    【HDOJ】1494 跑跑卡丁车
    【HDOJ】1495 非常可乐
    ACMer
    find the nth digit
    A C
    已知六条边的边长,求四面体体积
    快速排序
    {A} + {B}
    素数回文
  • 原文地址:https://www.cnblogs.com/huwt/p/10611977.html
Copyright © 2011-2022 走看看