JavaScript-function for to convert a dash-separated string into camel case
Yes, I think you should use String.prototype.replace instead of array looping. I think so because .replace is probably going to be faster and because the code will be easier to understand.

I would also like to warn you about equality operator (===) in JavaScript. This returns false:

"ddd"===new String("ddd")


This returns true:

"ddd"==new String("ddd")


Also try to avoid if( !xxx ) with variables that are not supposed to be boolean, because it can get quite confusing for people reading your code.

Here's the callback replacement you talked about. You should use that and improve it so that it fits your exact definition if the conversion, which is missing in the question, so it wasn't addressed.



// -------- THE ACTUAL FUNCTION -------------------------

/* blah blah blah */
function dashedToCamelCase( dashed ) {
  if( typeof dashed != "string" || dashed.length==0 )
    return "";
  return dashed.toLowerCase().replace(/\-([a-z]?)/g, function(match, letter) {
      return letter.toUpperCase();
  });
}

// -------- THE ACTUAL FUNCTION - END -------------------


// --- TESTING ---------------------------
var test = [ 'north',
             'north-east',
             'north-east-east',
             'south-west-west-north',
             'south-wEst-EaSt',
             'North-west-EAST',
             'NORTH-EAST-SOUTH-WEST',
             248,
             '' ];
var expect = [ 'north',
               'northEast',
               'northEastEast',
               'southWestWestNorth',
               'southWestEast',
               'northWestEast',
               'northEastSouthWest',
               '',
               '' ];

var output = document.getElementById("output");
test.forEach(function(item, i) {
  try {
    var result = dashedToCamelCase(item);
    if(result==expect[i]) {
      writeOutput(item+" =&gt; "+result, "correct");
    }
    else {
      writeOutput(item+" =&gt; "+"got '"+result+"' instead of '"+expect[i]+"'", "wrong");
    }
  }
  catch(e) {
    writeOutput(e.message, "error");
  }
});
function writeOutput(text, className) {
  var p = document.createElement("p");
  p.appendChild(new Text(text));
  p.className = className;
  output.appendChild(p);
}
.correct {
  color: green;
}
.wrong {
  color: red;
}
.error {
  font-weight: bold;  
  color: red;
}
&lt;pre id="output"&gt;&lt;/pre&gt;