JavaScript Strings — தமிழ்

</>Coding Tamilan.← JavaScript course

JavaScript · Lesson 15 / 32 · தமிழ்

JavaScript Strings

கருத்தைப் புரிந்துகொள்ளுங்கள். Code-ஐ மாற்றி இயக்குங்கள். ஒரு சிறிய பயிற்சியால் கற்றதை உறுதி செய்யுங்கள்.

Detailed notesRunnable JavaScriptPractice + answer

மூலப் பாட விளக்கங்கள் தமிழில் உள்ளன. கூடுதல் concept, practice மற்றும் answer notes ஆங்கிலத்தில் உள்ளன.

01 / Understand

முக்கியக் கருத்து

Strings hold text. Methods such as trim and toUpperCase return new strings rather than modifying the original value.

Learning goal: Explain what the example does, predict its result, and change it to solve the practice task.

02 / Explore

விரிவான விளக்கங்கள்

JavaScript-ல Strings

Strings என்பது characters-ன் sequences. JavaScript strings immutable — string methods எப்பவும் new string return பண்ணும்.

String Create பண்றது

JavaScript reference fragmentCODE
const single = 'Hello';
const double = "World";
const template = `Hello, ${"World"}!`; // Template literal (ES6)

// Multi-line string
const html = `
  <div>
    <h1>Title</h1>
  </div>
`;

console.log("Hello".length); // 5

Common String Methods

JavaScript reference fragmentCODE
const str = "  Hello, World!  ";

str.toUpperCase();      // "  HELLO, WORLD!  "
str.toLowerCase();      // "  hello, world!  "
str.trim();             // "Hello, World!"
str.includes("World");  // true
str.startsWith("  He"); // true
str.indexOf("o");       // 5
str.slice(2, 7);        // "Hello"
str.replace("World", "JS");
str.replaceAll("l", "L");
"a-b-c".split("-");     // ["a", "b", "c"]
"5".padStart(3, "0");   // "005"
"ha".repeat(3);         // "hahaha"

Template Literals

JavaScript reference fragmentCODE
const name = "Alice";
const age = 30;

// Expression interpolation
const msg = `My name is ${name} and I am ${age} years old.`;

console.log(`2 + 2 = ${2 + 2}`);
console.log(`Is adult: ${age >= 18 ? 'Yes' : 'No'}`);
03 / Read & predict

முழுமையான உதாரணம்

Run this complete index.js program in the JavaScript console editor below. The earlier reference fragments may need a browser page or other surrounding setup.

index.js · complete exampleCODE
const raw = "  coding tamilan  ";
const clean = raw.trim();
console.log(clean.toUpperCase());
console.log(clean.includes("tamil"));
எதிர்பார்க்கும் முடிவைப் பாருங்கள்
CODING TAMILAN
true
04 / Experiment

மாற்றி இயக்கிப் பாருங்கள்

Load the example, change a value, predict the output, and run it again. Use the console output to check your reasoning.

Open editor ↗

Editor load ஆனதும் code-ஐ ஏற்றி Run அழுத்துங்கள்.

OneCompiler என்ற இலவச வெளிப்புற சேவை code-ஐ இயக்குகிறது. Run செய்யும் code அங்கு அனுப்பப்படும். தனிப்பட்ட தகவல்கள் அல்லது secret keys உள்ளிட வேண்டாம்.

05 / Your turn

சிறிய பயிற்சி

Practice challenge

Replace tamil with JavaScript in clean and print the result.

விடை மற்றும் விளக்கம்

clean.replace("tamil", "JavaScript") produces "coding JavaScriptan" because replace matches the substring. Choose whole-word logic when that is the requirement.

தவிர்க்க வேண்டிய தவறு: String comparisons are case-sensitive. toUpperCase returns a value; it does not update the existing binding.

அடுத்த பாடத்திற்குத் தயாரா?

  • Explain the example in your own words.
  • Complete the challenge before revealing its answer.
  • Describe the common mistake and how to avoid it.
Coding Tamilan · Learn by doing.