Beginner Friendly · Hands-on · Free

Used to fetch the part of the given string on the basis of the specified starting position and lengt

substr() function இங்கு நாம் கொடுக்கும் position மற்றும் length ஐ பொருத்து குறிப்பிட்ட string ஐ fetch செய்து எடுப்பதற்கு பயன்படுகிறது.

5 min read Updated Dec 13, 2025

substr() Function in Javascript

substr() function இங்கு நாம் கொடுக்கும் position மற்றும் length ஐ பொருத்து குறிப்பிட்ட string ஐ fetch செய்து எடுப்பதற்கு பயன்படுகிறது.

string.substr(start,length)

Note: substr() function இங்கு start position மற்றும் length ஆகியன argument ஆக அனுபப்படுகிறது. இங்கு position மற்றும் length ஐ பொருத்து புதிய ஒரு string ஐ fetch செய்து எடுப்பதற்கு பயன்படுகிறது. இந்த function original string இல் எந்த மாற்றமும் செய்யாது.

Example1

<script>
var input = "Parallel Codes Youtube";
var res = input.substr(0,14);
document.writeln(res);
</script>

மேலே உள்ள Example1-ஐ கவனிக்கவும் இங்கு input என்ற variable இல் "Parallel Codes Youtube" என்ற string value ஆனது store செய்யபட்டுள்ளது.இங்கு input.substr(0,14) என்ற function பயன்படுத்தபடுகிறது, இங்கு substr() function இல் substr(0,14) 0,14 என்ற argument அனுபப்படுகிறது இங்கு 0 என்பது starting position மற்றும் 14 என்பது string length ஆகும். எனவே நமக்கு output ஆனது Parallel Codes என கிடைக்கிறது.

Output:

Parallel Codes

Example2

<script>
var data = "Linto.in Learn Programming in Tamil";
var res = data.substr(0,26);
document.writeln(res);
</script>

மேலே உள்ள Example2-ஐ கவனிக்கவும் இங்கு data என்ற variable இல் "Linto.in Learn Programming in Tamil" என்ற string value ஆனது store செய்யபட்டுள்ளது. இங்கு data.substr(0,26) என்ற function பயன்படுத்தபடுகிறது, இங்கு substr() function இல் substr(0,26) என்ற argument அனுபப்படுகிறது இங்கு 0 என்பது starting position மற்றும் 26 என்பது string length ஆகும். எனவே நமக்கு output ஆனது Linto.in Learn Programming என கிடைக்கிறது.output ஐ கவனிக்கவும்.

Output:

Linto.in Learn Programming

இது பற்றிய தங்களின் கருத்துகளை இங்கே பதிவிடுங்கள் . இது பயனுள்ளதாக விரும்பினால் மற்றவர்களுக்கும் இதை share செய்யுங்கள்.