Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
IT Security DownloadsGitHub Release: anomalyco/opencode v2.0.20 (29.09.2026)(29.09.2026 um 23:07 Uhr)
••
IT Security DownloadsGitHub Release: google-gemini/gemini-cli v0.62.0 (29.09.2026)(29.09.2026 um 23:17 Uhr)
•••
IT NachrichtenCodenames Party is the latest addition to Netflix Games(29.09.2026 um 23:00 Uhr)
••
IT NachrichtenDie FRITZ!Box 7690 bekommt als erstes FRITZ!OS 8.50(29.09.2026 um 22:55 Uhr)
••
Hacking & PentestingHacker auch wegen geplanter Morde verdächtigt - DACHIST.org(29.09.2026 um 20:45 Uhr)
•
IT Security DownloadsGitHub Release: anomalyco/opencode v2.0.20 (29.09.2026)(29.09.2026 um 23:07 Uhr)
••
IT Security DownloadsGitHub Release: google-gemini/gemini-cli v0.62.0 (29.09.2026)(29.09.2026 um 23:17 Uhr)
•••
IT NachrichtenCodenames Party is the latest addition to Netflix Games(29.09.2026 um 23:00 Uhr)
••
IT NachrichtenDie FRITZ!Box 7690 bekommt als erstes FRITZ!OS 8.50(29.09.2026 um 22:55 Uhr)
••
Hacking & PentestingHacker auch wegen geplanter Morde verdächtigt - DACHIST.org(29.09.2026 um 20:45 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

JavaScript String Methods Explained with Examples

1.String in Javascript A string in JavaScript is a data type used to store text. It is a sequence of characters such as letters, numbers, symbols, or spaces enclosed within quotes. Example `let name = "Hariharan"; let city =…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!




1.String in Javascript



A string in JavaScript is a data type used to store text.

It is a sequence of characters such as letters, numbers, symbols, or spaces enclosed within quotes.



Example




`let name = "Hariharan";
let city = 'Chennai';
let message = "Hai";`







In the above examples




  • "Hariharan" is a string


  • "Chennai" is a string


  • "Hai" is a string




Important Points




  • Strings can be created using single quotes (' '), double quotes (" "), or backticks ( ).


  • Strings are used to store text values.


  • A string can contain letters, numbers, symbols, and spaces.







2.Why We Use Strings in JavaScript



We use strings in JavaScript to store and work with text data. Most applications need to handle text such as names, messages, addresses, or descriptions.






3.String Methods in JavaScript



In JavaScript, a string is a sequence of characters used to represent text. JavaScript provides many built-in string methods that allow developers to manipulate, analyze, and transform text data easily.



These methods help perform operations such as finding characters, extracting parts of a string, changing case, removing spaces, and replacing text.



One important thing to remember is that strings in JavaScript are immutable. This means string methods do not change the original string. Instead, they return a new string with the result.



1.Length



Returns the length of a string.




`let text = "Hari";
console.log(text.length);`










Output
10






2.charAt()



Returns the character at a specific index.




`let text = "Hariharan";
console.log(text.charAt(4));`










`Output
h`






3.charCodeAt()



Returns the Unicode value of a character.




`let text = "A";
console.log(text.charCodeAt(0));`










`Output
65`






What is Unicode



Unicode is a universal character encoding standard used to represent characters from almost all languages in the world.



It assigns a unique numeric code (number) to every character.



This allows computers to store and display text consistently across different systems and languages.



4.String Concat



The concat() method in JavaScript is used to join two or more strings together and return a new combined string.



It does not modify the original strings.




`let text1 = "Bumrah";
let text2 = "Bowls a Yorker";

let result = text1.concat(" ", text2);

console.log(result);`










`Output
Bumrah Bowls a Yorker`






5.toLowerCase()



Converts all characters to lowercase.




`let text = "HARIHARAN";
console.log(text.toLowerCase());`










`Output
hariharan`






6.toUppercase()



Converts all characters to uppercase




`let text = "hariharan";
console.log(text.toLowerCase());`










`Output
HARIHARAN`






6.Slice



Extracts a portion of a string




`let text = "JavaScript";
console.log(text.slice(0,4));`










`Output
Java`






7.trim()



Removes extra spaces from the beginning and end of a string




`let text = "   Hello   ";
console.log(text.trim());`










`Output
Hello`








JavaScript indexOf() Method



The indexOf() method in JavaScript is used to find the position (index) of the first occurrence of a specified value in a string.



If the specified value is not found, the method returns -1.




`let text = "Hello World";

console.log(text.indexOf("World"));`










`Output
6`






Important Points




  • indexOf() returns the first occurrence of a value.


  • If the value is not found, it returns -1.


  • It is case-sensitive.


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten JavaScript String Methods Explained with Examples

Thematisch verwandte Begriffe: JavaScript, String, Methods, Explained · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
ZERO-DAY Kritische Sicherheitsmeldung
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag