2023-08-07T10:00:09.png

    var name = "helloworld";
//截取hello  从0开始,长度为5
var s = name.substr(0,5);

console.log(s);


//不填写长度,截取e后面的所有字符
    var e = name.substr(1);

    console.log(e);



    //负数,倒数第几个后面的字符串
    //-3  输出   rld
    var d = name.substr(-3);
    console.log(d);


    //第二个参数为负数,结果为空字符串
    var f = name.substr(5,-4);
    console.log(f);