- String.prototype.charAt()
- String.prototype.charCodeAt()
- String.prototype.concat()
- String.prototype.endsWith()
- String.prototype.fromCharCode()
- String.prototype.includes()
- String.prototype.indexOf()
- String.prototype.lastIndexOf()
- String.prototype.match()
- String.prototype.repeat()
- String.prototype.replace()
- String.prototype.search()
- String.prototype.slice()
- String.prototype.split()
- String.prototype.startsWith()
- String.prototype.substr()
- String.prototype.substring()
- String.prototype.toLowerCase()
- String.prototype.toUpperCase()
- String.prototype.trim()
Last active
October 12, 2021 13:45
-
-
Save acidtone/4f1bd6ffff85fc8f4fed359b619fe76b to your computer and use it in GitHub Desktop.
Javascript: String methods
This file contains hidden or 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
| /* 20 String Methods */ | |
| /* Source: Free Code Camp | |
| https://youtu.be/VRz0nbax0uI */ | |
| let stringOne = "freeCodeCamp is the best place to learn" | |
| let stringTwo = "frontend and backend development" | |
| // charAt() | |
| console.log('charAt -> ', stringOne.charAt(1)) | |
| // charCodeAt() | |
| console.log('charCodeAt -> ', stringOne.charCodeAt(1)) | |
| // concat() | |
| console.log('concat -> ', stringOne.concat(stringTwo)) | |
| // endsWith() | |
| console.log('endsWith -> ', stringOne.endsWith("to")) | |
| // fromCharCode() | |
| console.log('fromCharCode -> ', String.fromCharCode(114)) | |
| // includes() | |
| console.log('includes -> ', stringTwo.includes("end")) | |
| // indexOf() | |
| console.log('indexOf -> ', stringTwo.indexOf("end")) | |
| // lastIndexOf() | |
| console.log('lastIndexOf -> ', stringTwo.lastIndexOf("end")) | |
| // match() | |
| console.log('match -> ', stringTwo.match(/end/g)) | |
| // repeat() | |
| console.log('repeat -> ', stringOne.repeat(3)) | |
| // replace() | |
| console.log('replace -> ', stringTwo.replace(/end/g, "END")) | |
| // search() | |
| console.log('search -> ', stringTwo.search("end")) | |
| // slice() | |
| console.log('charAt -> ', stringTwo.slice(2, 4)) | |
| // split() | |
| console.log('split -> ', stringOne.split(" ")) | |
| // startsWith() | |
| console.log('startsWith -> ', stringOne.startsWith("free")) | |
| // substr() | |
| console.log('substr -> ', stringTwo.substr(2, 4)) | |
| // substring() | |
| console.log('substring -> ', stringTwo.substring(2, 4)) | |
| // toLowerCase() | |
| console.log('toLowerCase -> ', stringOne.toLowerCase()) | |
| // toUpperCase() | |
| console.log('toUpperCase -> ', stringOne.toUpperCase()) | |
| // trim() | |
| let stringThree = " Subscribe now! "; | |
| console.log('trim -> ', stringThree.trim()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment