contry

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
replace
function getFlagEmoji(countryCode) {
  return countryCode.toUpperCase().replace(/./g, char => 
      String.fromCodePoint(127397 + char.charCodeAt())
  );
}
getFlagEmoji('de')
getFlagEmoji('CH')
ready
original
function getFlagEmoji(countryCode) {
  const codePoints = countryCode
    .toUpperCase()
    .split('')
    .map(char =>  127397 + char.charCodeAt());
  return String.fromCodePoint(...codePoints);
}
getFlagEmoji('de')
getFlagEmoji('CH')
ready
spread + reduce template
function getFlagEmoji(countryCode) {
  return [...countryCode.toUpperCase()].map(char => 
      String.fromCodePoint(127397 + char.charCodeAt())
  ).reduce((a, b) => `${a}${b}`);
}
getFlagEmoji('de')
getFlagEmoji('CH')
ready
spread + reduce plus
function getFlagEmoji(countryCode) {
  return [...countryCode.toUpperCase()].map(char => 
      String.fromCodePoint(127397 + char.charCodeAt())
  ).reduce((a, b) => a + b);
}
getFlagEmoji('de')
getFlagEmoji('CH')
ready
join
function getFlagEmoji(countryCode) {
  return [...countryCode.toUpperCase()].map(char => 
      String.fromCodePoint(127397 + char.charCodeAt())
  ).join('');
}
getFlagEmoji('de')
getFlagEmoji('CH')
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.