Javascript in Hindi Array




JavaScript मे Array एक Special Variable होता है. Javascript Arrays मे आप एक या एक से ज्यादा Value को एक ही समय मे Add कर सकते है.

JavaScript मे Array को एक Unit या लगातार Memory Location मे Elements के Group को Represent करने के लिए उपयोग किया जाता है. प्रत्येक Elements जो आप Array मे Enter करते हो वह Zero से Start होने वाले Unique Number के साथ Array मे Stored किया जाता है.

JavaScript मे Arrays का उपयोग एक Single Variable मे एक से अधिक Value को Store करने के लिये किया जाता है. Array एक ही प्रकार के Elements को एक Fixed Size मे Sequential के रूप मे Store करता है.

उदाहरण के लिए यदि आप कुछ समय मे किसी User की Location को Track करना चाहते है तो आप एक Array मे X और y Value को Included कर सकते है Array x और y के Examples की तुलना मे अधिक है Indexed के माध्यम से आप Data या Elements को Array मे Stored कर सकते है या और आप Elements को Array से प्राप्त कर सकते है.

Syntax


var fruits = new Array( "mango", "orange", "banana" );


For Example

<!DOCTYPE html>
<html>
   <head>
      <title>JavaScript Array Example</title>
   </head>
   <body>
      <h2>JavaScript Arrays Example</h2>
      <p id="demo"></p>	
      <script type="text/javascript">
         var fruits = ["Mango", "Banana", "Orange"];
         document.getElementById("demo").innerHTML = fruits;
      </script>
   </body>
</html>

Output

Array Properties

Arrays मे अपने built-in Variables और Functions होते है जिनको Properties और Methods के रूप मे जाना जाता है.

Property Description
Constructor

Array Function के लिए एक Context देता है जो Object से बनाया जाता है.

Index

Index मे Property String को Zero Based पर Represent करता है.

Input

Input Property केवल Matches के द्वारा बनाया गया Array है.

Length

Length Property आपके Array की Length Hold करती है.

Prototype

Prototype आपको किसी Object के Attribute और Properties को Add करने की अनुमति देता है.

Array Constructor Property

Javascript Array Constructor Property Array Function का Reference देता है जिसने Instances Prototype बनाया है.

Syntax


array.constructor


For Example

<!DOCTYPE html>
<html>
   <head>
      <title>Array constructor Property</title>
   </head>
   <body>	
      <script type="text/javascript">
	
         var arr = new Array( 10, 20, 30 );
         document.write("arr.constructor is:" + arr.constructor);
			
      </script>
   </body>
</html>

Output

Array Length Property

JavaScript आपको Array Object के साथ Length Property Provide करती है. ये Property आपके Array की Length Hold करती है. Javascript मे Array Length Property को 32-bit Integer Unsigned देता है जो Array मे Element की संख्या को Define करता है.

Syntax


array.length


For Example

<!DOCTYPE html>
<html>
   <head>
      <title>Array Length Property</title>
   </head>
   <body>	
      <script type="text/javascript">
	
         var arr = new Array( 10, 20, 30 );
         document.write("arr.length is : " + arr.length);
			
      </script>
   </body>
</html>

Output

Array Prototype Property

Prototype Property आपको किसी भी Object मे Property को जोड़ने की अनुमति देता है (Number, Boolean, String and Date).

Syntax


object.prototype.name = value


For Example

<!DOCTYPE html>
<html>
   <head>
      <title>Array Prototype Property</title>
      <script type="text/javascript">
         function book(title, author){
            this.title = title; 
            this.author  = author;
         }
      </script>
		
   </head>
   <body>	
      <script type="text/javascript">
	
         var myBook = new book("java", "Ammu");
         book.prototype.price = null;
         myBook.price = 100;
         
         document.write("Book title is : " + myBook.title + "<br>");
         document.write("Book author is : " + myBook.author + "<br>");
         document.write("Book price is : " + myBook.price + "<br>");
			
      </script>
   </body>
</html>

Output