substr()中startPos大于length时,startPos值
var mystr=“Hello World!";
document.write(mystr.substr(20));
startPos大于length,执行后是空白。那么返回会的是空字符吗?
var mystr=“Hello World!";
document.write(mystr.substr(20));
startPos大于length,执行后是空白。那么返回会的是空字符吗?
2017-07-08
拿这个可以测试出来,如果是空字符的话a后面应该有空格
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script type="text/javascript">
var s="I love JavaScript!";
document.write("a"+s.substr(6)+"a");
document.write(s.substr(18)+s.length);
</script>
</head>
<body>
</body>
</html>
举报