Important Notice:

String Function

String Function

21 views 1 min read

2. String Function:-

जो functions string data यानी text पर काम करते हैं उन्हें String Functions कहते हैं।

इन functions का उपयोग text को modify, search, convert और manage करने के लिए किया जाता है।

जब हमें text को uppercase, lowercase या किसी word को search करना होता है तब string functions बहुत useful होते हैं।

Important String Functions:-

toUpperCase():-

यह function string को capital letters में बदल देता है।

Example:

 
let name = "rahul";

console.log(name.toUpperCase());
 

Output:

 
RAHUL
 

toLowerCase():-

यह function string को small letters में convert करता है।

Example:

 
let text = "HELLO";

console.log(text.toLowerCase());
 

Output:

 
hello
 

length:-

यह string की total length बताता है।

Example:

 
let text = "JavaScript";

console.log(text.length);
 

Output:

 
10
 

charAt():-

यह function किसी specific position का character निकालता है।

Example:

 
let name = "JavaScript";

console.log(name.charAt(0));
 

Output:

 
J
 

includes():-

यह check करता है कि कोई word string में मौजूद है या नहीं।

Example:

 
let msg = "Welcome Student";

console.log(msg.includes("Student"));
 

Output:

 
true
 

slice()

यह string का कुछ भाग निकालता है।

Example:

 
let text = "JavaScript";

console.log(text.slice(0, 4));
 

Output:

 
Java
 

replace()

यह function text को replace करता है।

Example:

 
let msg = "Hello Student";

console.log(msg.replace("Student", "Rahul"));
 

Output:

 
Hello Rahul
 

Real Life Use of String Functions

String functions का उपयोग कई जगहों पर किया जाता है जैसे:

  • Search systems
  • Login systems
  • Form validation
  • Text editing software
  • Chat applications
  • Data filtering systems

  •  

Related Notes