ucfirst de PHP en Javascript

function ucfirst(string){ return string.charAt(0).toUpperCase() + string.slice(1); } Por ejemplo: foo = ‘hello world!’; foo = ucfirst(foo); // Hello world! bar = ‘HELLO WORLD!’; bar = ucfirst(bar.toLowerCase()); // Hello world! Si la cadena esta entera en mayúsculas y se quiere tener sólo la primera, priemero se debería pasar toda a minúscula y después cambiar la primera.

Leer más