Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to Capitalize First Letter of String in JavaScript
// es5 way
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
// es6 way using destructuring
const capitalize = ([first,]) => first.toUpperCase() + rest.join('');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment