Last active
July 2, 2020 15:26
-
-
Save AEnMe/9b2fc12a7c0aff7731d9f9155f1a8ad3 to your computer and use it in GitHub Desktop.
stringMethod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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