JavaScript Syntax — தமிழ்

</>Coding Tamilan.← JavaScript course

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

JavaScript Syntax

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

Detailed notesRunnable JavaScriptPractice + answer

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

01 / Understand

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

Statements describe actions. Strings need matching quotes, identifiers are case-sensitive, and braces group statements into a block.

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

02 / Explore

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

JavaScript Syntax என்னன்னு பார்ப்போம்

JavaScript syntax என்பது ஒரு JS program எப்படி எழுதணும், எப்படி interpret ஆகும்னு சொல்ற rules. இந்த basics தெரிஞ்சா hard-to-find bugs வராம தடுக்கலாம்.

Statements மற்றும் Semicolons

JavaScript programs statements-ஆல ஆனது. Semicolon (;) ஒரு statement-ன் முடிவை குறிக்கும். JavaScript-ல Automatic Semicolon Insertion (ASI) இருக்கு — ஆனா அதை நம்பி விட்டா bugs வரும்.

JavaScript reference fragmentCODE
// ஒவ்வொரு statement-உம் ; -ல முடிக்கணும்
let x = 5;
let y = 10;
let sum = x + y;

// ASI gotcha — line-ஐ ( அல்லது [ -ல ஆரம்பிக்காதே
const fn = () => console.log("hi")
(function() { /* இது fn()-ஆ call ஆகிடும்! */ })()

Case Sensitivity

JavaScript reference fragmentCODE
// JavaScript CASE-SENSITIVE — கவனமா இரு
let name = "Alice";
let Name = "Bob";     // முற்றிலும் வேற variable!
let NAME = "Charlie"; // இதுவும் வேற!

// Keywords lowercase-ல இருக்கணும்
// Let x = 5;  // ❌ SyntaxError
let x = 5;     // ✅

Whitespace மற்றும் Indentation

JavaScript reference fragmentCODE
// JavaScript extra whitespace-ஐ ignore பண்ணும்
let x=5;       // works
let y = 5;     // works (இப்படி எழுதுவது readable!)

// 2 அல்லது 4 spaces indentation use பண்ணு
if (x > 0) {
  console.log("positive");
  if (x > 10) {
    console.log("large");
  }
}

Identifiers — பெயர் வைக்குற விதிகள்

Conventionஎதுக்கு use பண்றோம்Example
camelCaseVariables, functionsuserName, getTotal()
PascalCaseClasses, constructorsUserAccount, ShoppingCart
UPPER_SNAKE_CASEConstantsMAX_SIZE, API_URL
_prefixPrivate (convention)_internalState
$prefixDOM elements, libraries$element, jQuery

Tip: Descriptive names use பண்ணு. getUserById என்பது g அல்லது func1-ஐ விட மிகவும் better.

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 course = "JavaScript";
if (course === "JavaScript") {
  console.log("Ready to learn");
}
எதிர்பார்க்கும் முடிவைப் பாருங்கள்
Ready to learn
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

Change course to "Java". Will the message appear?

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

No. The strict equality check is false, so the block is skipped.

தவிர்க்க வேண்டிய தவறு: console.log and console.Log are different property names. A missing closing quote or brace is a syntax error.

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

  • 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.