JavaScript Kya Hai aur Ise Kaise Shuru Karein?

1. JavaScript (JS) Kya Hai?

JavaScript (JS) ek high-level, interpreted programming language hai. Web ki duniya mein, iski position HTML aur CSS ke saath sabse important hai:

  • HTML: Webpage ka structure define karta hai (jaise ek ghar ka dhangal – walls and rooms).
  • CSS: Webpage ki styling aur look-and-feel define karta hai (jaise ghar ko paint karna aur furniture lagana – paint and furniture).
  • JavaScript (JS): Webpage ka behavior aur interactivity define karta hai (jaise lights on/off karna ya AC chalana – functionality).

JS ki madad se, aap static pages ko dynamic banaate hain: button click hone par kuch change karna, form data check karna, ya bina page reload kiye naya content dikhana. Browser ke alawa, yeh Node.js ke through server side par bhi kaam karta hai.


2. Apna Environment Kaise Set Karein? (Setup) 🛠️

Aap do tarikon se coding start kar sakte hain:

A. Browser Console (Turant Testing ke Liye)

Agar aapko chota-mota code turant run karna hai, toh aapka browser hi kaafi hai:

  1. Developer Tools Kholo: Page par Right-click karo aur “Inspect” chuno, ya F12 press karo.
  2. Console Tab Par Jao: Wahaan “Console” naam ka tab milega, us par click karo.
  3. Code Run Karo: Prompt (jahaan > dikhta hai) par apna JS code type karke Enter daba do.
    • Example: console.log("Hello, Me Coder Hu!");

B. VS Code (Serious Coding ke Liye)

Bade projects ke liye, ek professional text editor chahiye, aur Visual Studio Code (VS Code) sabse best hai.

  1. VS Code Install Karo: Official site se download karke install kar lo.
  2. Files Banao: Ek naye folder mein do files banao:
    • index.html (Jismein webpage ka structure hoga)
    • script.js (Jismein aapka JavaScript code hoga)

3. JS ko HTML se Kaise Jodein? 🔗

JS ko HTML document mein add karne ka sabse achha tareeka hai External Script ka use karna.

External JavaScript (Best Practice)

Isse aapka HTML aur JS code alag-alag, clean rehta hai.

  1. script.js mein code likho:JavaScript// script.js let meraNaam = "Me Coder Hu"; console.log("Mera channel naam hai: " + meraNaam);
  2. index.html mein link karo:Aapko <script> tag ka use karke file link karni hai. Is tag ko hamesha closing </body> tag se just pehle rakho. Isse aapki HTML page content pehle load ho jaati hai, aur phir JS chalta hai.HTML<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Mera Pehla JS Project</title> </head> <body> <h1>Me Coder Hu - JS Seekho!</h1> <script src="script.js"></script> </body> </html>

MeCoderHu
https://mecoderhu.com

Leave a Reply