TestingDocs.com logoTestingDocs.com
Automation learning lab
TestingDocs • Self-paced course

Playwright Automation
Self Study Guide

Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.

60 chaptersBeginner friendlyHands-on practice
JavaScript / Chapter 11 of 60~12 min • Beginner
Chapter 11JavaScript

Arrays

Arrays hold ordered collections with zero-based indexes. length gives the number of items. push appends a value and pop removes the last item. Arrays are useful for test inputs and expected results.

How it works

Step-by-step walkthrough

  1. Create an array
  2. Access its first item
  3. Append an item

Example

JavaScript
const cases = ['login', 'logout'];
cases.push('search');
console.log(cases[0], cases.length);
Expected result: login 3
💡 Point to remember
Do not use index 1 for the first item.

✎ Your practice task

Remove the final item with pop.

Knowledge check

What is the index of the first item?

🌐 Continue learning