My Book

trim

trim方法实现1:

    function fn(str){

        let reg = /^\s+|\s+$/g;
        str = str.replace(reg,"");
        return str;
    }