Skip to content

Instantly share code, notes, and snippets.

@AEnMe
Last active July 2, 2020 15:26
Show Gist options
  • Save AEnMe/9b2fc12a7c0aff7731d9f9155f1a8ad3 to your computer and use it in GitHub Desktop.
Save AEnMe/9b2fc12a7c0aff7731d9f9155f1a8ad3 to your computer and use it in GitHub Desktop.
stringMethod
myString = "abcdef";
// Outputs 2 characters, starting after the first character.
myString.substr(1, 2)
//"bc"
// Outputs everything after the first character, through the second character.
myString.substring(1)
//"bcdef
// Converts the string to all uppercase letters.
myString.toUpperCase()
//"ABCDEF"
// Converts the string to all lowercase letters.
myString.toLowerCase()
//"abcedf"
// Returns the last character of a string.
myString.slice(-1)
//"f"
// Returns a string as an array with items split at the specified character.
myString.split("c")
//["ab","def"]
// Returns the string repeated x times
myString.repeat(3)
//"abcdefabcdefabcdef"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment