Try this:
var camelCased = myString.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
The regular expression will match the -i
in marker-image
and capture only the i
. This is then uppercased in the callback function and replaced.