2. Group Members
• M.Tayyab
• Hassan Dar
• Saddam Butt
• Bilal Khan
3. TOPICS
• Arrays
• Declaring and Allocating Array
• Types of Array
• Array Methods
• Array Attributes
4. Arrays
• Array inherits from Object.
• Indexes are converted to strings and
used as names for retrieving values.
• Very efficient for sparse arrays.
• Not very efficient in most other cases.
• One advantage: No need to provide a
length or type when creating an array.
5. Declaring and Allocating Arrays
• JavaScript arrays are Array objects.
• Creating new objects using the new
operator is known as creating an
instance or instantiating an object
• Operator new is known as the dynamic
memory allocation operator
6. Declare + Initialize Arrays
var array_name = [“a” , ”b” , ”c”];
Using the JavaScript Keyword new
8. Associative Array
(keys and values) var person = [];
person [“ firstName "] = “Hassan";
person [“ lastName "] = "Dar";
OR
9. Indexing Array
Array elements are accessed using their index number:
var ary = [“A” , “B” , “C” , “D” , “E” , “F”];
document.write(ary[4]); //output : E
31. Deleting Elements
delete array[number]
• Removes the element, but leaves
a hole in the numbering.
array.splice(number, 1)
• Removes the element and
renumbers all the following
elements.