Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "string/starts-with/docs/types/index.d"

Index

Functions

Functions

Export assignment startsWith

  • startsWith(str: string, search: string, position?: undefined | number): boolean
  • Tests if a string starts with the characters of another string.

    Parameters

    • str: string

      input string

    • search: string

      search string

    • Optional position: undefined | number

      position at which to start searching (default: 0)

    Returns boolean

    boolean indicating if the input string starts with the search string

    Example

    var bool = startsWith( 'Remember the story I used to tell you when you were a boy?', 'Remember' );
    // returns true

    Example

    var bool = startsWith( 'Remember the story I used to tell you when you were a boy?', 'Remember, remember' );
    // returns false

    Example

    var bool = startsWith( 'To be, or not to be, that is the question.', 'To be' );
    // returns true

    Example

    var bool = startsWith( 'To be, or not to be, that is the question.', 'to be' );
    // returns false

    Example

    var bool = startsWith( 'To be, or not to be, that is the question.', 'to be', 14 );
    // returns true

    Example

    var bool = startsWith( 'To be, or not to be, that is the question.', 'quest', -9 );
    // returns true