ChemPal Documentation - v1.6.0
    Preparing search index...

    Function ucfirst

    • Converts the first character of a string to uppercase.

      Parameters

      • str: string

        The string to convert.

      Returns string

      The string with the first character converted to uppercase.

      ucfirst("hello") // Returns "Hello"
      ucfirst("world") // Returns "World"
      ucfirst("") // Returns ""
      ucfirst(null) // Returns null
      ucfirst(undefined) // Returns undefined
      ucfirst("123") // Returns "123"
      ucfirst("123abc") // Returns "123abc"
      ucfirst("123ABC") // Returns "123ABC"
      ucfirst("123abcABC") // Returns "123abcABC"
      ucfirst("123abcABC") // Returns "123abcABC"
      export function ucfirst(str: string): string {
      if (!str) {
      return str;
      }

      return str.charAt(0).toUpperCase() + str.slice(1);
      }