JavaScript Academy · Lesson

Array CRUD, Iteration; Object Basics & Access

Array CRUD and iteration; object literals and property access with dot/bracket and optional chaining.

Lesson 1 of 28 steps

Array CRUD, Iteration; Object Basics & Access is a free JavaScript Academy lesson on CoddyKit. This is lesson 1 of 2. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the JavaScript Academy learning path, and your progress syncs across the web and the CoddyKit app. The JavaScript Academy course includes 2 lessons in total.

Intro

Goal: Handle arrays and objects with simple, safe patterns.

  • Array CRUD
  • Iterate values
  • Object access
Array CRUD, Iteration; Object Basics & Access — illustration 1

Array CRUD basics

Use push/unshift to add, pop/shift to remove. Keep prints short for mobile.

// Make an array
const colors = ["red", "green"];

// Add to end
colors.push("blue");

// Add to start
colors.unshift("pink");

// Remove from end
const last = colors.pop();

// Remove from start
const first = colors.shift();

console.log("Colors now:", colors);
console.log("Removed:", first, last);
Array CRUD, Iteration; Object Basics & Access — illustration 2

Index & length

Use index access and length for simple reads.

// Read by index and use length
const nums = [10, 20, 30];

console.log("First:", nums[0]);
console.log("Last:", nums[nums.length - 1]);
console.log("Count:", nums.length);
Array CRUD, Iteration; Object Basics & Access — illustration 3

Array iteration

for…of yields values directly; forEach calls a function for each value.

// Iterate values with for…of
const fruits = ["apple", "banana", "cherry"];

for (const value of fruits) {
  console.log("of:", value);
}

// Or use forEach with a small callback
fruits.forEach(function (v) {
  console.log("each:", v);
});
Array CRUD, Iteration; Object Basics & Access — illustration 4

Object literals & access

Objects store key–value pairs. Use dot or bracket access.

// Create an object with properties
const user = {
  name: "Ayla",
  level: 1,
  active: true
};

// Dot access
console.log("Name:", user.name);

// Bracket access (useful for dynamic keys)
const key = "level";
console.log("Level:", user[key]);
Array CRUD, Iteration; Object Basics & Access — illustration 5

Optional chaining & spread

?. avoids errors when a path is missing. Use ... spread to clone and to merge objects (later keys override earlier ones).

// Optional chaining: safely read nested values
const profile = { contact: { email: "ayla@example.com" } };
console.log("Email:", profile.contact?.email);
console.log("Twitter:", profile.social?.twitter);

// Clone and merge with spread
const base = { a: 1, b: 2 };
const extra = { b: 9, c: 3 };

const clone = { ...base };
const merged = { ...base, ...extra };

console.log("Clone:", clone);
console.log("Merged:", merged);
Array CRUD, Iteration; Object Basics & Access — illustration 6

Array method quiz

Quick check: Add to the end of an array.

Array CRUD, Iteration; Object Basics & Access — illustration 7

Recap

Recap: You practiced array CRUD, iterated with for…of/forEach, accessed object properties, used optional chaining, and cloned/merged with spread.

Array CRUD, Iteration; Object Basics & Access — illustration 8
Free to start

Learn JavaScript with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
59
Lessons
200

Frequently Asked Questions

Is the “Array CRUD, Iteration; Object Basics & Access” lesson free?

Yes — any 3 lessons of the JavaScript Academy learning path, including “Array CRUD, Iteration; Object Basics & Access”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The JavaScript Academy course includes 2 lessons in total.

What will I learn in “Array CRUD, Iteration; Object Basics & Access”?

Array CRUD and iteration; object literals and property access with dot/bracket and optional chaining. You practise JavaScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start JavaScript Academy?

No prior experience is required. JavaScript Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 1 of 2.

How long does the “Array CRUD, Iteration; Object Basics & Access” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this JavaScript Academy lesson?

Yes. Every JavaScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Array CRUD, Iteration; Object Basics & Access
  2. Cloning & Merging — spread and Object.assign
← Back to JavaScript Academy