shineYao

下划线字符串camel

const camel = (str) => {
    let slices = str.split('_');
    let result = [];
    for(let i = 1, len = slices.length; i < len; i++) {
        slices[i] = slices[i].charAt(0).toUpperCase() + slices[i].substring(1);
    }
    return slices.join('');
}

posted on 2017-09-09 20:07  shineYao  阅读(161)  评论(0编辑  收藏  举报

导航