← Back to JavaScript Course | Chapter 1: Basics & Syntax | Lesson 1 of 12

JS परिचय

Think of a web page built with only HTML and CSS as a beautifully printed poster, it looks great, but it can never react to you. Nothing moves, nothing responds, nothing changes after it's printed. JavaScript is what turns that poster into something alive. It's the programming language that runs inside your browser and lets a page respond to clicks, validate a form before it's submitted, update content without reloading, and generally behave like a real application instead of a static document. Today JavaScript runs almost everywhere, not just in browsers on cookiescursor.com around the world, but also on servers, in mobile apps, and even on small devices, all using the same core language.

JavaScript क्या है

JavaScript एक हल्की, interpreted programming language है जिसे browsers स्वाभाविक रूप से समझते हैं, और जो developers को page का व्यवहार नियंत्रित करने, user की क्रियाओं पर प्रतिक्रिया देने और सामग्री को गतिशील रूप से अपडेट करने देती है।

Note: JavaScript आज़माने के लिए आपको कुछ install करने की ज़रूरत नहीं, हर आधुनिक browser में एक built-in console होता है जहाँ आप इसे तुरंत चला सकते हैं।
Warning: JavaScript code placed directly in HTML runs as soon as the browser reaches it, so placement in the page matters for what elements are available yet.

उदाहरण: What JavaScript Is

javascript
document.body.style.backgroundColor = "lightyellow";
console.log("JavaScript updates the page without reloading it.");

JavaScript क्यों बनी

JavaScript इसलिए बनाई गई थी कि web pages हर क्रिया के लिए पूरे page को दोबारा load किए बिना interactive हो सकें, जिससे page input को validate कर सकता है, elements को animate कर सकता है और चलते-चलते नया data fetch कर सकता है।

Note: जब भी कोई webpage आपको तुरंत जवाब देता है, चाहे वह dropdown menu हो या live search, वह तात्कालिक प्रतिक्रिया लगभग हमेशा JavaScript का ही काम होती है।
Warning: Overusing JavaScript for things HTML and CSS already handle well, like simple layout, can make a page slower and harder to maintain.

उदाहरण: Why JavaScript Exists

javascript
document.body.addEventListener("click", function () {
  // Print "Page responded instantly, no reload needed." to the console
  // Print "Page responded instantly, no reload needed." to the console
  console.log("Page responded instantly, no reload needed.");
});

JavaScript क्या-क्या कर सकती है

साधारण interactivity से आगे, JavaScript webpage के हर हिस्से में हेरफेर कर सकती है, दूसरे servers से data fetch कर सकती है, browser में जानकारी store कर सकती है, और पूरे applications बना सकती है जो desktop software जैसे लगते हैं।

Note: छोटे, दिखने वाले प्रभावों से शुरुआत कीजिए, जैसे menu को toggle करना, वे आगे बड़े applications की नींव बनाते हैं।
Warning: JavaScript has access to a lot of browser capability, so scripts from untrusted sources can pose real security risks, always review third party code carefully.

उदाहरण: What JavaScript Can Do

javascript
// Assign "<p>Content added dynamically by JavaScript.</p>" to `document.body.innerHTML`
// Assign "<p>Content added dynamically by JavaScript.</p>" to `document.body.innerHTML`
document.body.innerHTML = "<p>Content added dynamically by JavaScript.</p>";
// Call `localStorage.setItem("visited", "true")`
// Call `localStorage.setItem("visited", "true")`
localStorage.setItem("visited", "true");
// Print `"Stored data:", localStorage.getItem("visited")` to the console
// Print `"Stored data:", localStorage.getItem("visited")` to the console
console.log("Stored data:", localStorage.getItem("visited"));

Browser बनाम Server पर JavaScript

Client-side JavaScript visitor के browser के अंदर चलती है ताकि वे जो देखें और जिससे interact करें उसे नियंत्रित करे, जबकि server-side JavaScript, Node.js जैसे environments का उपयोग करके, server पर चलती है ताकि requests संभाले, databases से बात करे और data को browser तक पहुँचने से पहले तैयार करे।

Note: Browser के लिए जो JavaScript syntax आप सीखते हैं, वही सीधे Node.js जैसे server-side environments में भी काम करता है, दोनों तरफ़ के लिए एक ही भाषा।
Warning: Browser JavaScript cannot directly access a visitor's file system or a private database, those tasks are handled by server-side code for security reasons.

उदाहरण: JavaScript in the Browser vs on the Server

javascript
// Client-side JavaScript runs inside the browser
console.log("Running in the browser, window exists:", typeof window !== "undefined");
// Server-side JavaScript (Node.js) runs on a server instead, with no window object

JavaScript के Versions

JavaScript को ECMAScript के रूप में standardize किया गया है, और भाषा क्रमांकित संस्करणों के ज़रिए विकसित हुई है, जिनमें ES6 (2015) ने let, const, arrow functions और classes जैसी प्रमुख सुविधाएँ पेश कीं जिन्हें अब आधुनिक JavaScript का मानक माना जाता है।

Note: जब tutorials ES6 या 'modern JavaScript' का ज़िक्र करते हैं, तो उनका मतलब 2015 के ECMAScript अपडेट में और उसके बाद आई syntax से होता है।
Warning: Very old browsers may not support the newest JavaScript syntax, for international audiences with varied devices, checking compatibility tables is worthwhile for critical features.

उदाहरण: JavaScript Versions

javascript
// ES6 (2015) introduced let, const, arrow functions, and classes
const greet = (name) => `Hello, ${name}!`;
console.log(greet("World"));
Live Example
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
🔒

Chapter Quiz — Complete all 12 topics to unlock

0/12 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.