為什么這里“hello”可以提取,“world”就不能了。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>string對(duì)象</title>
<script type="text/javascript">
var mystr="Hello World!"
document.write(mystr ? ? ? ? + "<br />");
document.write(mystr.substring("H",5) ? ? ? ? + "<br />");
document.write(mystr.substring("W") ? ? ? ? ? ? ? ? ? );
</script>
</head>
<body>
</body>
</html>
2016-12-28
substring(),括號(hào)內(nèi)必須是一個(gè)非負(fù)整數(shù),寫(xiě)字母是無(wú)效的,所以應(yīng)該寫(xiě)成,document.write(mystr.substring(0,5));
document.write(mystr.substring(5));
2017-08-22
....如果第一個(gè)位置寫(xiě)的不是非負(fù)數(shù)字,默認(rèn)從頭開(kāi)始,不新你可以吧“H”換成“e”,結(jié)果是一樣的
2016-12-28
mystr.indexOf(" ")z這個(gè)也可以、mystr.indexOf("W")也可以
2016-12-28
substring(5)我直接這么打的
2016-12-28
("W",) ?呢個(gè)點(diǎn)。。是、不是、 有問(wèn)題..我也剛看這節(jié)