<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[JavaScript Arrays 101]]></title><description><![CDATA[JavaScript Arrays 101]]></description><link>https://arraysinjs99.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 17:30:25 GMT</lastBuildDate><atom:link href="https://arraysinjs99.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[📚 JavaScript Arrays 101]]></title><description><![CDATA[Imagine you want to store:

5 favorite movies

10 student marks

A list of daily tasks


You could create separate variables like this:
let movie1 = "Inception";
let movie2 = "Interstellar";
let movie]]></description><link>https://arraysinjs99.hashnode.dev/javascript-arrays-101-beginners-guide</link><guid isPermaLink="true">https://arraysinjs99.hashnode.dev/javascript-arrays-101-beginners-guide</guid><category><![CDATA[JavaScript #WebDevelopment #Programming #FrontendDevelopment #JavaScriptArrays #Arrays #LearnJavaScript #Coding #SoftwareDevelopment #JavaScriptForBeginners]]></category><dc:creator><![CDATA[Sheikh Ilyas Quadri]]></dc:creator><pubDate>Sun, 22 Feb 2026 10:49:19 GMT</pubDate><enclosure url="https://cloudmate-test.s3.us-east-1.amazonaws.com/uploads/covers/6735777588a43a34d0f85c8f/112d04ae-6b2a-427a-a7a2-c4c6db988511.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Imagine you want to store:</p>
<ul>
<li><p>5 favorite movies</p>
</li>
<li><p>10 student marks</p>
</li>
<li><p>A list of daily tasks</p>
</li>
</ul>
<p>You <em>could</em> create separate variables like this:</p>
<pre><code class="language-plaintext">let movie1 = "Inception";
let movie2 = "Interstellar";
let movie3 = "Avatar";
</code></pre>
<p>But what if you have 100 values?</p>
<p>That’s messy.</p>
<p>This is where <strong>arrays</strong> help.</p>
<hr />
<h1>📌 What Are Arrays?</h1>
<p>An <strong>array</strong> is a collection of multiple values stored in a single variable.</p>
<p>Think of it like a row of boxes:</p>
<pre><code class="language-plaintext">[ value, value, value, value ]
</code></pre>
<p>Arrays store values in <strong>order</strong> and each value has a position called an <strong>index</strong>.</p>
<hr />
<h1>🏗️ How to Create an Array</h1>
<p>We use square brackets <code>[]</code> to create an array.</p>
<h3>Example: List of Fruits</h3>
<pre><code class="language-plaintext">let fruits = ["Apple", "Banana", "Mango", "Orange"];
</code></pre>
<p>Now all fruits are stored inside one variable.</p>
<p>Much cleaner than creating 4 separate variables.</p>
<hr />
<h1>📊 Visual Representation of an Array</h1>
<pre><code class="language-plaintext">Index:   0        1        2        3
        --------------------------------
Value:  Apple   Banana   Mango   Orange
</code></pre>
<p>⚠ Important: Indexing starts from <strong>0</strong>, not 1.</p>
<p>That’s very important in JavaScript.</p>
<hr />
<h1>🔎 Accessing Elements Using Index</h1>
<p>To access a value, use its index number.</p>
<pre><code class="language-plaintext">let fruits = ["Apple", "Banana", "Mango"];

console.log(fruits[0]);  // Apple
console.log(fruits[1]);  // Banana
</code></pre>
<p>Structure:</p>
<pre><code class="language-plaintext">fruits[index]
</code></pre>
<p>If you try to access a non-existing index:</p>
<pre><code class="language-plaintext">console.log(fruits[10]);
</code></pre>
<p>It will return:</p>
<pre><code class="language-plaintext">undefined
</code></pre>
<hr />
<h1>🔄 Updating Array Elements</h1>
<p>You can change values using index.</p>
<pre><code class="language-plaintext">let fruits = ["Apple", "Banana", "Mango"];

fruits[1] = "Grapes";

console.log(fruits);
</code></pre>
<p>Before:</p>
<pre><code class="language-plaintext">["Apple", "Banana", "Mango"]
</code></pre>
<p>After:</p>
<pre><code class="language-plaintext">["Apple", "Grapes", "Mango"]
</code></pre>
<p>Arrays are mutable — meaning values can be changed.</p>
<hr />
<h1>📏 The <code>length</code> Property</h1>
<p>To know how many elements are in an array, use <code>.length</code>.</p>
<pre><code class="language-plaintext">let fruits = ["Apple", "Banana", "Mango"];

console.log(fruits.length);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">3
</code></pre>
<p>Useful when looping through arrays.</p>
<hr />
<h1>🔁 Looping Over Arrays</h1>
<p>To print all elements, we can use a simple <code>for</code> loop.</p>
<pre><code class="language-plaintext">let fruits = ["Apple", "Banana", "Mango"];

for (let i = 0; i &lt; fruits.length; i++) {
  console.log(fruits[i]);
}
</code></pre>
<p>How it works:</p>
<ol>
<li><p>Start from index 0</p>
</li>
<li><p>Continue until <code>i &lt; fruits.length</code></p>
</li>
<li><p>Print each element</p>
</li>
</ol>
<hr />
<h1>🧠 Memory-Style Block Diagram</h1>
<p>Think of array storage like this:</p>
<pre><code class="language-plaintext">fruits
   ↓
 -------------------------
 | Apple | Banana | Mango |
 -------------------------
    0        1        2
</code></pre>
<p>Each value occupies a position in memory.</p>
<hr />
<h1>🆚 Individual Variables vs Array</h1>
<h3>❌ Without Array</h3>
<pre><code class="language-plaintext">let mark1 = 85;
let mark2 = 90;
let mark3 = 78;
</code></pre>
<p>Hard to manage.</p>
<hr />
<h3>✅ With Array</h3>
<pre><code class="language-plaintext">let marks = [85, 90, 78];
</code></pre>
<p>Cleaner. Scalable. Easier to loop.</p>
<hr />
<h1>💡 Final Thoughts</h1>
<p>Arrays are one of the most important data structures in JavaScript.</p>
<p>They are used in:</p>
<ul>
<li><p>Storing API data</p>
</li>
<li><p>Managing lists</p>
</li>
<li><p>Working with loops</p>
</li>
<li><p>Building real-world applications</p>
</li>
</ul>
<p>If you understand:</p>
<ul>
<li><p>Indexing</p>
</li>
<li><p>Updating</p>
</li>
<li><p>Length</p>
</li>
<li><p>Looping</p>
</li>
</ul>
<p>You’re building strong fundamentals.</p>
<p>Advanced array methods (map, filter, reduce) come next — but mastering the basics first is very important.</p>
]]></content:encoded></item></channel></rss>