Methods

  • Methods are actions we can perform, JavaScript provides a number of string methods.

  • These methods are called or used by appending an instance with:

    • a period (the dot operator)

    • the name of the method

    • opening and closing parentheses

e.g. 'example string'.methodName()

Some Methods:

  1. console.log('hello'.toUpperCase()) Output: 'HELLO'

  2. console.log('Hey'.startsWith('H')) Output: true

  3. console.log(' Remove Whitespace '.trim()) Output: Remove Whitespace

Last updated