JavaScript · Lesson 02 / 32 · தமிழ்
JavaScript தொடங்குவோம்
கருத்தைப் புரிந்துகொள்ளுங்கள். Code-ஐ மாற்றி இயக்குங்கள். ஒரு சிறிய பயிற்சியால் கற்றதை உறுதி செய்யுங்கள்.
மூலப் பாட விளக்கங்கள் தமிழில் உள்ளன. கூடுதல் concept, practice மற்றும் answer notes ஆங்கிலத்தில் உள்ளன.
முக்கியக் கருத்து
You can begin in a browser console or the editor below. Run a small script first, then move it into a project file. Browser page scripts can use a deferred external script so the HTML is parsed before the script runs.
Learning goal: Explain what the example does, predict its result, and change it to solve the practice task.
விரிவான விளக்கங்கள்
JavaScript எப்படி Run பண்றது?
JavaScript எங்கயும் run ஆகும் — browser-ல, Node.js-ல server-ல, desktop apps-லயும் கூட. Start பண்ண எந்த installation-உம் தேவையில்ல.
1. Browser Console
JavaScript try பண்ண fastest way — browser-ல built-in console.
- எந்த browser-உம் open பண்ணு (Chrome, Firefox, Edge)
- F12 press பண்ணு (அல்லது right-click → Inspect)
- Console tab-ல click பண்ணு
- JavaScript type பண்ணி Enter press பண்ணு
DevTools Console
> console.log("Hello, World!");
Hello, World!
< undefined
> 2 + 2
< 4
> [1,2,3].map(x => x * 2)
< [2, 4, 6]2. HTML-ல JavaScript
எந்த HTML page-லயும் <script> tag மூலம் JavaScript add பண்ணலாம்.
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1 id="title">Hello</h1>
<!-- Script-ஐ </body>-க்கு முன்னாடி வை -->
<script src="script.js"></script>
</body>
</html>// script.js
document.getElementById("title").textContent = "Hello from JavaScript!";3. Node.js (Server-side)
Node.js-ஐ use பண்ணா JavaScript-ஐ browser இல்லாம — உன்னோட computer-லயோ server-லயோ run பண்ணலாம்.
- nodejs.org-ல இருந்து Node.js download பண்ணு
hello.jsன்னு file create பண்ணு- Terminal-ல run பண்ணு:
node hello.js
Terminal
$ node hello.js
Hello from Node.js!
Node version: v21.0.0| Environment | எப்படி run பண்றது | Use case |
|---|---|---|
| Browser Console | F12 → Console tab | Quick experiments |
| HTML + Script tag | .html-ஐ browser-ல open பண்ணு | Web pages |
| Node.js | node filename.js | Server, scripts, CLIs |
| Online editors | codepen.io, jsfiddle.net | Sharing & demos |
முழுமையான உதாரணம்
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.
console.log("My first JavaScript session");
console.log(12 + 8);எதிர்பார்க்கும் முடிவைப் பாருங்கள்
My first JavaScript session 20
மாற்றி இயக்கிப் பாருங்கள்
Load the example, change a value, predict the output, and run it again. Use the console output to check your reasoning.
Editor load ஆனதும் code-ஐ ஏற்றி Run அழுத்துங்கள்.
OneCompiler என்ற இலவச வெளிப்புற சேவை code-ஐ இயக்குகிறது. Run செய்யும் code அங்கு அனுப்பப்படும். தனிப்பட்ட தகவல்கள் அல்லது secret keys உள்ளிட வேண்டாம்.
சிறிய பயிற்சி
Practice challenge
Print your name on one line and 7 multiplied by 6 on the next.
விடை மற்றும் விளக்கம்
Use console.log("Your name"); followed by console.log(7 * 6);. The second line is 42.
தவிர்க்க வேண்டிய தவறு: Do not include the Console prompt symbol > when copying a command. Browser DOM APIs are not available in every JavaScript runtime.
அடுத்த பாடத்திற்குத் தயாரா?
- Explain the example in your own words.
- Complete the challenge before revealing its answer.
- Describe the common mistake and how to avoid it.