W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
substring()方法返回String對象的子集。
string.substring(indexA, [indexB])
indexA - 一個(gè)介于0和1之間的整數(shù),小于字符串的長度。
indexB - (可選)0到字符串長度之間的整數(shù)。
substring方法根據(jù)給定的參數(shù)返回新的子字符串。
var str = "Apples are round, and apples are juicy."; console.log("(1,2): " + str.substring(1,2)); console.log("(0,10): " + str.substring(0, 10)); console.log("(5): " + str.substring(5));
在編譯時(shí),它將在JavaScript中生成相同的代碼。
其輸出如下:
(1,2): p (0,10): Apples are (5): s are round, and apples are juicy.
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: