v1
7/30/2025 by cdsb -00
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
const str = "hello world! this is jsbench. café résumé";

function capitalizeFirst_charAt(str) {
  return str && str.charAt(0).toUpperCase() + str.slice(1);
}

function capitalizeFirst_replaceStart(str) {
  return str && str.replace(/^./, c => c.toUpperCase());
}

function capitalizeFirst_index(str) {
  return str && str[0].toUpperCase() + str.slice(1);
}

String.prototype.capitalizeFirst_prototype = function () {
  return this.charAt(0).toUpperCase() + this.slice(1);
};

function capitalizeFirstLetter(s) {
  return s && s[0].toUpperCase() + s.slice(1);
}

function capitalizeWords_unicode(str) {
  if (!str) return str;
  return str.replace(/(^|[^\p{L}\p{N}_])(\p{L}\p{M}*)/gu, (_, pre, word) => pre + capitalizeFirstLetter(word));
}
delete caserun single casemove downdrag and drop case


ready



capitalizeFirst_replaceStart(str);
delete caserun single casemove upmove downdrag and drop case


ready



capitalizeFirst_charAt(str);
delete caserun single casemove upmove downdrag and drop case


ready



capitalizeFirst_index(str);
delete caserun single casemove upmove downdrag and drop case


ready



str.capitalizeFirst_prototype();
delete caserun single casemove updrag and drop case


ready



capitalizeWords_unicode(str);
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN