Related Topics

what is Protocols in Hindi

What is a Program in Hindi

What is a Secure Connection in Hindi

Introduction to WWW in Hindi

What are Development Tools in Hindi

What is a Web Browser in Hindi

What is a Server in Hindi

What is a UNIX Web Server in Hindi

What is Logging Users in Hindi

What is Dynamic IP Web Design in Hindi

Web Site Design Principles in Hindi

Introduction to Site Planning and Navigation in Hindi

what is Web Systems Architecture in Hindi

Architecture of Web-Based Systems in Hindi

Client-Server Architecture in Hindi

What is Caching in Hindi

: Proxies in Hindi

What is an Index in Hindi

What is a Load Balancer in Hindi

What is a Queue in Hindi

Web Application Architecture in Hindi

JavaScript in Hindi

Client-Side Scripting in Hindi

Introduction to Simple JavaScript in Hindi

: JavaScript Variables in Hindi

What is a Function in JavaScript in Hindi

What are Loops in JavaScript in Hindi

What is Repetition (Looping) in JavaScript? in Hindi

What is an Object in JavaScript in Hindi

JavaScript Own Objects in Hindi

What is DOM in Hindi

What is a Web Browser Environment in Hindi

Forms in JavaScript in Hindi

DHTML in Hindi

What are Events in DHTML in Hindi

Browser Control in JavaScript in Hindi

AJAX in Hindi

AJAX-based Web Application in Hindi

Alternatives to AJAX in Hindi

XML in Hindi

Uses of XML in Hindi

Simple XML in Hindi

XML Key Components in Hindi

What is DTD (Document Type Definition) in Hindi

What is XML Schema (XSD) in Hindi

XML with Application in Hindi

XSL in Hindi

XSLT in Hindi

Web Service in hindi

PHP in Hindi

Server-Side Scripting in Hindi

PHP Arrays in Hindi

PHP Functions in Hindi

PHP Forms in Hindi

Advanced PHP Databases in Hindi

Introduction to Basic Commands in PHP in Hindi

Server Connection in PHP in Hindi

Database Creation in PHP in Hindi

Understanding Database Selection in PHP in Hindi

PHPMyAdmin in Hindi

Database Bugs in Hindi

PHP Database Query in Hindi

Related Subjects

What are Conditions in JavaScript in Hindi

/ DIPLOMA_CSE / Web Technology

What are Conditions in JavaScript in Hindi

Conditions in JavaScript

JavaScript में Conditions का उपयोग किसी condition (शर्त) के आधार पर code के execution को control करने के लिए किया जाता है। यह हमें यह निर्णय लेने की अनुमति देता है कि code का कौन सा हिस्सा execute होगा। Conditions के द्वारा हम यह निर्धारित करते हैं कि क्या कोई विशिष्ट condition सही (true) है या गलत (false)। यदि condition सही है, तो corresponding block of code execute होता है।

JavaScript में कई प्रकार के condition structures होते हैं, जैसे कि If statement, If-Else statement, Else-If statement, और Switch statement। इनका उपयोग विभिन्न परिस्थितियों में किया जाता है।

If Statement in JavaScript in Hindi

If Statement

If statement का उपयोग किसी शर्त (condition) को check करने के लिए किया जाता है। यदि वह शर्त सही (true) होती है, तो उसके अंदर का code block execute होता है। इसे सबसे साधारण प्रकार का conditional statement कहा जा सकता है।

  • Syntax:
    if (condition) {
      // Code to be executed if condition is true
    }
  • Example:
    let age = 18;
    if (age >= 18) {
      console.log("You are eligible to vote.");
    }

If-Else Statement in JavaScript in Hindi

If-Else Statement

If-Else statement का उपयोग तब किया जाता है जब हम दो विकल्पों में से एक को चुनना चाहते हैं। यदि If condition सही (true) होती है, तो पहला block execute होगा, अन्यथा दूसरा block (else) execute होगा।

  • Syntax:
    if (condition) {
      // Code to be executed if condition is true
    } else {
      // Code to be executed if condition is false
    }
  • Example:
    let age = 16;
    if (age >= 18) {
      console.log("You are eligible to vote.");
    } else {
      console.log("You are not eligible to vote.");
    }

Else-If Statement in JavaScript in Hindi

Else-If Statement

Else-If statement का उपयोग तब किया जाता है जब हमें कई conditions को check करना हो। हम else-if के साथ multiple conditions जोड़ सकते हैं और code block को condition के हिसाब से execute करवा सकते हैं।

  • Syntax:
    if (condition1) {
      // Code to be executed if condition1 is true
    } else if (condition2) {
      // Code to be executed if condition2 is true
    } else {
      // Code to be executed if none of the conditions are true
    }
  • Example:
    let age = 25;
    if (age < 18) {
      console.log("You are a minor.");
    } else if (age >= 18 && age < 60) {
      console.log("You are an adult.");
    } else {
      console.log("You are a senior citizen.");
    }

Switch Statement in JavaScript in Hindi

Switch Statement

Switch statement का उपयोग तब किया जाता है जब हम एक ही variable के अलग-अलग values के आधार पर code execute करना चाहते हैं। यह कई conditions को check करने के लिए एक बेहतर विकल्प है, जब हमें if-else का उपयोग करने पर code बहुत लंबा और जटिल हो जाए।

  • Syntax:
    switch (expression) {
      case value1:
        // Code to be executed if expression equals value1
        break;
      case value2:
        // Code to be executed if expression equals value2
        break;
      default:
        // Code to be executed if expression doesn't match any case
    }
  • Example:
    let day = 3;
    switch (day) {
      case 1:
        console.log("Monday");
        break;
      case 2:
        console.log("Tuesday");
        break;
      case 3:
        console.log("Wednesday");
        break;
      default:
        console.log("Invalid day");
    }

FAQs

If Statement ek conditional statement hai jiska use kisi condition ko check karne ke liye kiya jata hai. Agar condition true hoti hai, to uske andar likha code execute hota hai. Agar condition false hoti hai, to code execute nahi hota.

If Statement mein sirf ek condition check hoti hai aur agar wo condition true hoti hai, to uske andar ka code execute hota hai. Jabki If-Else statement mein agar condition true hoti hai to first block execute hota hai, aur agar condition false hoti hai, to else block execute hota hai.

Else-If statement ka use multiple conditions ko check karne ke liye hota hai. Jab pehli condition false hoti hai, to dusri condition check hoti hai. Agar koi bhi condition true hoti hai, to uska corresponding code block execute hota hai.

Switch statement ka use ek hi variable ki different values ko check karne ke liye kiya jata hai. Ismein hum case blocks define karte hain aur jo case value match karti hai, uska corresponding code execute hota hai.

Switch statement ka use karne se code clean aur readable rehta hai jab humare paas multiple conditions hoti hain. If-Else statements ki jagah Switch ka use karna code ko concise banata hai, jisse errors kam hoti hain.

Agar hum Switch statement mein "break" nahi lagate hain, to program control next case ko bhi execute kar leta hai, chahe wo match na bhi kare. Isko "fall-through" behavior kaha jata hai, jo ki unwanted results de sakta hai.

Please Give Us Feedback