首页 > 其他 > 详细

21-2-substring

时间:2019-09-07 12:42:25      阅读:163      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body {
            font-family: "Microsoft YaHei", serif;
        }

        body, dl, dd, p, h1, h2, h3, h4, h5, h6 {
            margin: 0;
        }

        ol, ul, li {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        img {
            border: none
        }
    </style>
</head>
<body>

<script>

    let a = "abc张宇1234567";

    let b = a.substring(3,5); //如果写了负数会认为是0,这个可以5,3

    console.log(b);

    let c = a.slice(-5,-2);  //这个可以是负数,这个不可以5,3
    console.log(c);


</script>
</body>
</html>

 

21-2-substring

原文:https://www.cnblogs.com/zhangyu666/p/11480087.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!