0Pricing
JavaScript Academy · Lesson

Array CRUD, Iteration; Object Basics & Access

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

Array CRUD, Iteration; Object Basics & Access is a free JavaScript Academy lesson on CoddyKit — lesson 1 of 2. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the JavaScript Academy learning path, one of 2 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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

Frequently asked questions

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

Yes — the full text of “Array CRUD, Iteration; Object Basics & Access” is free to read here on the web, and the JavaScript Academy course includes 2 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the JavaScript Academy course, upgrade to CoddyKit PRO.

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; this is — lesson 1 of 2, so you can start here or from the beginning and move at your own pace.

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