Every line of 'tocapitalize javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
145 function capitalize(string) { 146 return string.replace(/^[a-z]/, function(str) { 147 return str.toUpperCase(); 148 }); 149 }
7 capitalize(str) { 8 if (!str) { 9 return str; 10 } 11 return str.replace(/^(.)/, c => c.toUpperCase()); 12 }