Unleash the Power of JavaScript String Methods - Your Ultimate Cheat Sheet 🤯🔥
Ram Maheshwari ♾️
Posted on February 1, 2023
JavaScript strings are a powerful tool for manipulating text and working with data. To get the most out of your strings, you'll want to familiarize yourself with the various string methods available in JavaScript 🔥
In this article, I'll provide you with an ultimate cheat sheet for JavaScript string methods, making it easy to find exactly what you need to accomplish your goals 🚀
With clear code examples and descriptions, you'll learn how to use each method to perform common string operations like finding substrings, converting case, and removing whitespace 😎
Whether you're a seasoned JavaScript developer or just starting out, this cheat sheet will be a valuable resource for optimizing your string-based code ⚡
So, Let's get started 🤖
1) str.length
: returns the length of a string.
2) str.charAt(index)
: returns the character at the specified index in a string.
3) str.indexOf(searchValue[, fromIndex])
: returns the index of the first occurrence of the specified value in a string.
4) str.lastIndexOf(searchValue[, fromIndex])
: returns the index of the last occurrence of the specified value in a string.
5) str.substring(start[, end])
: returns a new string that is a substring of the original string.
6) str.substr(start[, length])
: returns a new string that is a part of the original string.
7) str.toLowerCase()
: returns a new string with all characters in lower case.
8) str.toUpperCase()
: returns a new string with all characters in upper case.
9) str.trim()
: removes whitespace from both ends of a string
10) str.replace(searchValue, replaceValue)
: replaces all occurrences of the specified value in a string with another value.
Hope this is helpful ✨
Do Like ❤️ & Save 🔖
Do 𝗙𝗼𝗹𝗹𝗼𝘄 me on Linkedin for more:
Tips💡+ Guides📜 + Resources ⚡ related to Programming and Web Development 👨💻
Do Follow me here on dev.to ✅
Posted on February 1, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
February 1, 2023