Skip to content

Commit

Permalink
chore: Update string methods in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
manthanank committed Aug 10, 2024
1 parent d866397 commit 53bd27c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,7 @@ const name = 'Manthan';
The following are some of the most commonly used string methods in JavaScript:
- **at()**
- **charAt()**
- **charCodeAt()**
- **concat()**
Expand All @@ -1416,19 +1417,39 @@ The following are some of the most commonly used string methods in JavaScript:
- **length**
- **localeCompare()**
- **match()**
- **matchAll()**
- **padEnd()**
- **padStart()**
- **prototype**
- **repeat()**
- **replace()**
- **replaceAll()**
- **search()**
- **slice()**
- **split()**
- **startsWith()**
- **substr()**
- **substring()**
- **toLocaleLowerCase()**
- **toLocaleUpperCase()**
- **toLowerCase()**
- **toString()**
- **toUpperCase()**
- **trim()**
- **trimEnd()**
- **trimStart()**
- **valueOf()**
[Back to Top⤴️](#table-of-contents)
**at()** - Returns the character at a specified index (position)
```javascript
let myString = "Hello World!";

console.log(myString.at(0)); // Output: "H"
```
**charAt()** - Returns the character at a specified index (position)
```javascript
Expand Down Expand Up @@ -1541,6 +1562,39 @@ console.log(myString); // Output: "The quick brown fox jumps over the lazy dog."
console.log(result); // Output: ["the", index: 30, input: "The quick brown fox jumps over the lazy dog.", groups: undefined]
```
**matchAll()** - Returns an iterator of all results matching a string against a regular expression
```javascript
let myString = "The quick brown fox jumps over the lazy dog.";

let result = myString.matchAll(/the/gi);

console.log(myString); // Output: "The quick brown fox jumps over the lazy dog."
console.log(result); // Output: [RegExpStringIterator]
```
**padEnd()** - Pads a string with a specified value at the end
```javascript
let myString = "Hello";

let newString = myString.padEnd(10, " World!");

console.log(myString); // Output: "Hello"
console.log(newString); // Output: "Hello World!"
```
**padStart()** - Pads a string with a specified value at the start
```javascript
let myString = "Hello";

let newString = myString.padStart(10, " World!");

console.log(myString); // Output: "Hello"
console.log(newString); // Output: " World!Hello"
```
[Back to Top⤴️](#table-of-contents)
**prototype** - Allows you to add properties and methods to an object
Expand Down

0 comments on commit 53bd27c

Please sign in to comment.