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

Site Planning in Hindi

Website 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

What is an Object in JavaScript in Hindi

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

JavaScript Own Objects in Hindi

RGPV University / DIPLOMA_CSE / Web Technology

JavaScript Own Objects in Hindi

JavaScript में Own Objects का मतलब होता है कि आप खुद से एक नया Object बनाएँ, जिसमें आप अपनी आवश्यकताओं के अनुसार अलग-अलग Properties और Methods जोड़ सकते हैं। यह विशेष रूप से तब उपयोगी होता है जब आपको किसी विशिष्ट डेटा को संग्रहित करने और उसे विभिन्न प्रकार से प्रबंधित करने की आवश्यकता होती है।

Creating Own Objects in JavaScript in Hindi

JavaScript में खुद के Objects बनाने के लिए आप दो मुख्य तरीकों का उपयोग कर सकते हैं:

  • Object Literal Syntax: यह सबसे सरल और सामान्य तरीका है। इस तरीके से आप सीधे Object को डिफाइन करते हैं।
  • Constructor Function: इस तरीके में आप एक Constructor Function बनाते हैं और फिर उसे नया Object बनाने के लिए इस्तेमाल करते हैं।

अब हम इन्हें विस्तार से समझते हैं:

Object Literal Syntax

यह तरीका बहुत आसान है, जिसमें आप Object को सीधे इस तरह से define कर सकते हैं:

let person = { name: "John", age: 30, city: "New York" };

यहाँ पर, person एक Object है जिसमें name, age, और city Properties हैं।

Constructor Function

आप एक constructor function बनाकर भी object create कर सकते हैं। यह तरीका reusable होता है और Object की Properties को dynamically set कर सकता है:

function Person(name, age, city) { this.name = name; this.age = age; this.city = city; } let person1 = new Person("John", 30, "New York");

इस प्रकार, हम अलग-अलग Objects को एक ही constructor function से बना सकते हैं।

Accessing Own Properties in JavaScript in Hindi

JavaScript में जब आप खुद का Object बनाते हैं, तो आप उसके अंदर मौजूद Properties को access कर सकते हैं। इसके दो मुख्य तरीके होते हैं:

  • Dot Notation: इसका मतलब है कि आप Object की Property को डॉट (.) का उपयोग करके access करते हैं।
  • Bracket Notation: इसमें आप Property का नाम ब्रैकेट्स [] के अंदर एक string के रूप में देते हैं।

Dot Notation

Dot notation में आप सीधे Object की Property को dot (.) के बाद उसका नाम लिखकर access करते हैं। उदाहरण:

let person = { name: "John", age: 30, city: "New York" }; console.log(person.name); // Output: John

Bracket Notation

Bracket notation में आप Property का नाम string के रूप में लिखते हैं। यह तब उपयोगी होता है जब Property का नाम variable हो या एकदम खास characters हों। उदाहरण:

let person = { name: "John", age: 30, city: "New York" }; console.log(person["age"]); // Output: 30

Enumerating Own Properties in JavaScript in Hindi

JavaScript में Object की सभी Properties को एक-एक करके देखने के लिए, आप for...in loop का उपयोग कर सकते हैं। यह loop आपको Object की सभी own properties पर iterate करने का मौका देता है।

Example of Enumerating Own Properties

यहाँ एक उदाहरण है, जिसमें हम Object की सभी properties को enumerate कर रहे हैं:

let person = { name: "John", age: 30, city: "New York" }; for (let key in person) { console.log(key + ": " + person[key]); }

Output:

name: John age: 30 city: New York

इस तरीके से हम Object की सारी Properties को देख सकते हैं।

Modifying Own Properties in JavaScript in Hindi

JavaScript में आप Object की Properties को आसानी से modify (update) कर सकते हैं। इसके लिए आप Dot notation या Bracket notation का उपयोग कर सकते हैं।

Dot Notation Example

यहाँ हम एक Object की Property को modify कर रहे हैं:

let person = { name: "John", age: 30, city: "New York" }; person.age = 31; // Age property को update किया गया console.log(person.age); // Output: 31

Bracket Notation Example

Bracket notation का उपयोग करके भी हम Properties को modify कर सकते हैं:

let person = { name: "John", age: 30, city: "New York" }; person["city"] = "Los Angeles"; // City property को update किया गया console.log(person.city); // Output: Los Angeles

FAQs

Own Objects in JavaScript are objects created by the programmer using either Object Literal Syntax or Constructor Function. These objects contain user-defined properties and methods.
You can create your own Object in JavaScript using either Object Literal Syntax or Constructor Function. The Object Literal Syntax is the most commonly used approach.
Dot Notation is a simple way to access an object's property by using a dot (.) followed by the property name. Example: object.propertyName.
Bracket Notation allows you to access an object's properties by using square brackets []. This is especially useful when property names are dynamic or contain special characters.
You can modify the properties of an Object using Dot or Bracket Notation. Just assign a new value to the property to change it.
You can loop through the properties of an Object using a for...in loop. This loop iterates over each property of the object.

Please Give Us Feedback