Hello Dev Community! 👋
It is officially Day 13 of my journey toward mastering the MERN stack! Today, I moved on to Lecture 4 of Apna College's JavaScript playlist with Shradha Didi, leaving primitive single variables behind and entering the world of Arrays.
Up until yesterday, if I had to store 5 student names, I had to create 5 different variables. Today, I learned how to store them inside a single collection.
🧠Key Learnings From JS Lecture 4 (Arrays)
I explored the structure of Arrays in JavaScript and how they allow us to manage linear lists of items efficiently:
1. What is an Array?
An array is a linear collection of elements. Unlike some other languages, JavaScript arrays can store different data types together (though storing the same type is best practice).
- Arrays are Zero-Indexed (the first item is at position
0). - They have a built-in
.lengthproperty that tells us exactly how many items are inside.
2. Array Mutability vs String Immutability
A huge conceptual breakthrough today was learning that Arrays are mutable in JavaScript. Unlike strings (where methods return a new value), we can directly change an item in an array using its index:
javascript
let marks = [95, 82, 99];
marks[1] = 85; // Changes 82 to 85 directly in the original array!
Top comments (0)