Camel Case <= > :
: String , .
camelCase , .
String.prototype.camelToHyphen = function() {
return this.replace(/((?!^)[A-Z])/g, '-$1').toLowerCase();
};
.
String.prototype.hyphenToCamel = function() {
return (/-[a-z]/g.test(this)) ? this.match(/-[a-z]/g).map(function(m, n){
return m.replace(n, n.toUpperCase()[1]);
}, this) : this.slice(0);
};
I believe these are common problems, but I could not find anything that summarized them that way.
source
share