substring相關(guān)
<!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.substring(6)+"<br/>")
document.write(mystr.substring(0,mystr.indexOf(" ")))
// var mystr="Hello World!"
// document.write( ? ? ? ? + "<br />");
// document.write( ? ? ? ? ? ? ? ? ? );
</script>
</head>
<body>
</body>
</html>
上面第8行處6改為5不應(yīng)該有一個(gè)空格輸出嗎?怎么沒(méi)有呢?
2016-12-14
如果輸出結(jié)果的首位是空格,那么系統(tǒng)會(huì)自動(dòng)省略空格的。不能說(shuō)沒(méi)有!
2016-12-10
有空格輸出,你改成4就能看的很清楚