Converts underscored or add dash string to a camelized one - Node.js String

Node.js examples for String:Case

Description

Converts underscored or add dash string to a camelized one

Demo Code


/**//from   ww  w .j a va2  s  .c o m
 * converts underscored or dasherized string to a camelized one
 * @returns String camelized version
 */
camelize: function() {
  return this.replace(/(\-|_)+(.)?/g, function(match, dash, chr) {
    return chr ? chr.toUpperCase() : '';
  });
},

Related Tutorials