淺談JavaScript中的String對象常用方法

來源:互聯網
上載者:User

淺談JavaScript中的String對象常用方法

  這篇文章主要介紹了JavaScript中的String對象常用方法,非常簡單實用,有需要的小夥伴參考下

  String對象提供的方法用於處理字串及字元。

  常用的一些方法:

  charAt(index):返回字串中index處的字元。

  indexOf(searchValue,[fromIndex]):該方法在字串中尋找第一次出現的searchValue。如果給定了fromIndex,則從字串內該位置開始搜尋,當searchValue找到後,返回該串第一個字元的位置。

  lastIndexOf(searchValue,[fromIndex]):從字串的尾部向前搜尋searchValue,並報告找到的第一個執行個體。

  substring(indexA,indexB):擷取從indexA到indexB的子串

  toLowerCase():將字串中的所有字元全部轉換成小寫

  toUpperCaser():將字串中的所有字元全部轉換為大寫

 

  小夥伴們是否瞭解了String對象的用法了呢,希望大家能夠喜歡本文。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.