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:
Output:
toLowerCase():-
यह function string को small letters में convert करता है।
Example:
Output:
length:-
यह string की total length बताता है।
Example:
Output:
charAt():-
यह function किसी specific position का character निकालता है।
Example:
Output:
includes():-
यह check करता है कि कोई word string में मौजूद है या नहीं।
Example:
Output:
slice()
यह string का कुछ भाग निकालता है।
Example:
Output:
replace()
यह function text को replace करता है।
Example:
Output:
Real Life Use of String Functions
String functions का उपयोग कई जगहों पर किया जाता है जैसे: