0% found this document useful (0 votes)
11 views

Introduction to Javascript Arrays

An array in JavaScript is a collection of multiple values stored in a single variable, identified by an index starting from 0. Arrays can hold different types of values, but typically contain similar types. JavaScript offers built-in methods for common array operations, such as push(), pop(), unshift(), shift(), indexOf(), length, and sort().

Uploaded by

sushminkv2619
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Introduction to Javascript Arrays

An array in JavaScript is a collection of multiple values stored in a single variable, identified by an index starting from 0. Arrays can hold different types of values, but typically contain similar types. JavaScript offers built-in methods for common array operations, such as push(), pop(), unshift(), shift(), indexOf(), length, and sort().

Uploaded by

sushminkv2619
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Introduction to javascript arrays:

What is an Array?
• An array is a collection of multiple values stored inside a single
variable.
• Arrays can store values of different types, but usually store similar
types (like names, numbers, etc.).
• Each value in an array is identified by an index, starting from 0
(zero).
Example:
let cars = ["Volvo", "BMW", "Audi", "Benz"];
• cars[0] → "Volvo"
• cars[1] → "BMW"
• cars[2] → "Audi"
• cars[3] → "Benz"
Built-in Array Methods:
JavaScript provides methods to perform common array operations easily.
push() - Adds a new element at the end of the array.
pop() - Removes the last element from the array.
unshift() - Adds a new element at the beginning of the array.
shift() - Removes the first element of the array.
indexOf() - Returns the first index at which a given element is found.
- Returns -1 if the element is not found.
length - Returns the total number of elements in the array.
sort() - method sorts the elements alphabetically (A-Z order).

You might also like