Convert snake-case to camelCase

Source: https://coderwall.com/p/iprsng/convert-snake-case-to-camelcase

function snakeToCamel(s){
    return s.replace(/(\-\w)/g, function(m){return m[1].toUpperCase();});
}
or as more readable code


var snakeCaseString = 'lorem-ipsum';

var find = /(\-\w)/g;
var convert =  function(matches){
    return matches[1].toUpperCase();
};
var camelCaseString = snakeCaseString.replace(
    find,
    convert
);

Không có nhận xét nào:

URL parameters with React Router

 https://ui.dev/react-router-url-parameters If you're reading this, you're probably familiar with the idea of function parameters. T...