Converts a hyphenated string to camel case, ex: 'my-module' returns 'myModule' - Node.js String

Node.js examples for String:Case

Description

Converts a hyphenated string to camel case, ex: 'my-module' returns 'myModule'

Demo Code


String.prototype.toCamelCase = function () {
  return this.toString().toLowerCase().replace(/(-[a-z])/g, function ($1) {
    return $1.toUpperCase().replace('-', '');
  });/*  ww w .  j  a  va2s.c om*/
};

Related Tutorials