js

1.

// 驼峰命名
    console.log(hump('border-bottom-color'))
    function  hump( str) {
        if (typeof str != 'string') return;
        var arr = str.split("-");
        var newStr = arr[0];
        for(var i = 1; i < arr.length; i++) {
            newStr += arr[i].charAt(0).toLocaleUpperCase() + arr[i].substring(1);
        }
        return newStr;
    }

    console.log(humpReg("border-bottom-color-size"))
    function humpReg(str) {
        var re = /-(w)/g;
        str = str.replace(re, function (s) {
            return s.slice(1).toUpperCase();
        })
        return str;
    }
原文地址:https://www.cnblogs.com/bravolove/p/6116235.html