DEV/javascript, jQuery
[javascript] underber to camel, camel to underbar
꼭두새벽에비명소리
2020. 10. 28. 15:35
function underToCamel(str){
return str.toLowerCase().replace(/(\_[a-z])/g, function(arg){
return arg.toUpperCase().replace('_','');
});
}
function camelToUnderber(str){
return str.replace(/([A-Z])/g, function(arg){
return "_"+arg.toLowerCase();
}).toUpperCase();
}