Function isWhitespace

  • Category

    Check whether a string is empty or whitespace.

    Time complexity: O(1)

    Space complexity: O(1)

    Parameters

    • string: string

      String to check

    Returns boolean

    Whether the string is whitespace

    String

    isWhitespace(' \n '); // true
    
    isWhitespace(''); // true