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 Conditions in JavaScript in Hindi

What are Loops in JavaScript in Hindi

What is Repetition (Looping) 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 is an Object in JavaScript in Hindi

DIPLOMA_CSE / Web Technology

What is an Object in JavaScript in Hindi

JavaScript mein object ek data structure hota hai jo multiple values ko ek single entity ke roop mein store karta hai. Object ko key-value pairs ke roop mein define kiya jata hai. Object ki keys (properties) ko strings ke roop mein define kiya jata hai, aur unki values kisi bhi type ki ho sakti hain, jaise numbers, strings, arrays, ya doosre objects.

Object ko create karte waqt, hum key-value pairs define karte hain, jisme key ek unique identifier hota hai aur value usse related data hoti hai. JavaScript mein objects bohot important hote hain, kyunki ye data ko organize karne aur structured way mein store karne mein madad karte hain.

Example:

let student = { name: "Ravi", age: 20, marks: 85 };

Creating Objects in JavaScript in Hindi

JavaScript mein objects banane ke kai tareeqe hote hain. Sabse basic tareeka hai object literal ka use karna. Object literal ek object ko directly define karne ka tareeka hai, jisme hum key-value pairs specify karte hain.

  • Object Literal Method: Ye sabse commonly used method hai jisme hum object ko direct curly braces ({}) ke andar define karte hain.
  • Using the Object Constructor: Is method mein hum new Object() ka use karke object create karte hain.

Example:

// Object literal let person = { name: "John", age: 25 }; // Using Object constructor let car = new Object(); car.make = "Toyota"; car.model = "Corolla"; car.year = 2020;

Accessing Object Properties in JavaScript in Hindi

Jab object create hota hai, tab uski properties ko access karne ke liye hume unki keys ka use karte hain. JavaScript mein object ki properties ko do tareeqon se access kiya ja sakta hai: dot notation aur bracket notation.

  • Dot Notation: Isme hum object ke naam ke baad dot (.) laga kar property ko access karte hain.
  • Bracket Notation: Isme hum property name ko quotes mein rakh kar square brackets ([]) ka use karte hain.

Example:

let person = { name: "Amit", age: 30 }; // Dot notation console.log(person.name); // Amit // Bracket notation console.log(person["age"]); // 30

Modifying Object Properties in JavaScript in Hindi

JavaScript mein object properties ko modify karna bohot asaan hota hai. Hum dot notation ya bracket notation ka use karke kisi bhi property ki value ko badal sakte hain.

Example:

let person = { name: "Sita", age: 28 }; // Using dot notation person.name = "Geeta"; // Using bracket notation person["age"] = 29; console.log(person); // {name: "Geeta", age: 29}

Object Methods in JavaScript in Hindi

Object methods JavaScript mein functions hote hain jo objects ke andar define kiye jate hain. Ye methods object ki properties ko manipulate karne ya kisi bhi specific task ko perform karne ke liye use kiye jate hain.

  • Method Definition: A method can be defined inside an object, where it behaves like a property but is actually a function.
  • Calling Object Methods: Just like properties, we can call methods using dot notation.

Example:

let calculator = { num1: 10, num2: 20, add: function() { return this.num1 + this.num2; } }; console.log(calculator.add()); // 30

Object Constructor in JavaScript in Hindi

Object constructor ek built-in JavaScript function hai jiska use new object create karne ke liye hota hai. Is method ka use karte hue, hum object ko dynamically create kar sakte hain.

  • Using the Object Constructor: Isme hum new Object() likh kar ek empty object create karte hain.
  • Adding Properties to Object: Hum baad mein object ki properties ko add kar sakte hain.

Example:

let person = new Object(); person.name = "Rahul"; person.age = 22; console.log(person); // {name: "Rahul", age: 22}

Object Destructuring in JavaScript in Hindi

Object destructuring ek JavaScript feature hai jisme hum object ke properties ko directly variables mein assign kar sakte hain. Is technique ka use code ko zyada readable aur concise banane ke liye hota hai.

  • Destructuring Syntax: Hum object ke properties ko ek block ke andar curly braces mein likhte hain, aur unhe variables ke saath map karte hain.
  • Nested Destructuring: Agar object mein nested objects hain, toh unhe bhi destructure kiya ja sakta hai.

Example:

let person = { name: "Ravi", age: 25, address: { city: "Delhi", zip: "110001" } }; // Destructuring let { name, age, address: { city, zip } } = person; console.log(name); // Ravi console.log(city); // Delhi

FAQs

JavaScript mein object ek data structure hota hai jo key-value pairs ke roop mein data store karta hai. Har object ki ek ya adhik properties hoti hain jo kisi bhi data type ko represent kar sakti hain, jaise numbers, strings, arrays, ya doosre objects.

JavaScript mein object ko create karne ke liye do tareeqe hain: object literal aur Object constructor. Object literal ka use karte hue, hum object ko directly curly braces ({}) mein define karte hain. Object constructor ka use karte hue, hum new Object() likhte hain aur baad mein usme properties add karte hain.

JavaScript mein object ki properties ko access karne ke liye hum dot notation (object.property) ya bracket notation (object["property"]) ka use kar sakte hain. Dot notation zyada common hai, jabki bracket notation tab use hota hai jab property name dynamic ho.

JavaScript mein object properties ko modify karne ke liye, hum dot notation ya bracket notation ka use karte hain. Bas property ko naye value ke saath assign karna hota hai. Jaise object.property = newValue ya object["property"] = newValue.

JavaScript mein object methods wo functions hote hain jo object ke andar define kiye jate hain. Ye methods object ki properties ko manipulate karte hain ya specific tasks perform karte hain. Object methods ko access karne ke liye hum dot notation ka use karte hain.

Object destructuring ek feature hai jisme hum object ki properties ko directly variables mein assign kar sakte hain. Ye technique code ko zyada readable aur concise banati hai. Hum object ke keys ko directly variable names ke roop mein map karte hain.

object dot notation constructor

Please Give Us Feedback