UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

15 lines (14 loc) 464 B
export function lcfirst(str) { // discuss at: https://locutus.io/perl/lcfirst/ // parity verified: Perl 5.40 // original by: Kevin van Zonneveld (https://kvz.io) // example 1: lcfirst('HELLO') // returns 1: 'hELLO' // example 2: lcfirst('Hello') // returns 2: 'hello' const value = String(str); if (!value) { return ''; } return value.charAt(0).toLowerCase() + value.slice(1); }