SlideShare a Scribd company logo
1 of 7
Arrays
Definition
• An array is a special variable, which can hold
more than one value at a time.
• They are a place in memory that can store
multiple values
Creating an Array
1. Using an array literal
- Syntax : var array-name = [item1, item2, ...];
- e.g: var cars = [“Toyota", "Volvo", "BMW"];
2. Using the Keyword new:
- e.g: var cars = new Array(" Toyota ", "Volvo",
"BMW");
Accessing arrray elements
• We can can access array elements using array
name and element index.
• Arrays indexed by numbers beginning from 0
upward.
• e.g: in the previous example if we want to
change the second element, we use :
cars[1] = “Tucson";
Displaying array elements
• To display array elements we go through the
elements using for loop.
• Here we know the number of the elements by
using length attribute of the array. e.g:
cars.length
• e.g:
for(var i=0;i<cars.length;i++)
Document.write(cars[i]+”<br>”);
Two dimensional arrays
• They are array which their elements are also
arrays.
• To declare a 2D array:
Var numbers=[[1,2,3],[4,5]];
• To change the value of 4 to 6:
Numbers[1][0]=6;
Cont…
• To display the elements we use nested for loop.
e.g:
for(var i=0;i<numbers.length;i++)
{
for(var j=0;j<numbers[i].length;j++)
{
Document.write(numbers[i][j]+”<br>”);
}
}

More Related Content

Viewers also liked

JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript FunctionsBrian Moschel
 
Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]Aaron Gustafson
 
LinkedIn TBC JavaScript 100: Functions
 LinkedIn TBC JavaScript 100: Functions LinkedIn TBC JavaScript 100: Functions
LinkedIn TBC JavaScript 100: FunctionsAdam Crabtree
 
JavaScript Arrays
JavaScript Arrays JavaScript Arrays
JavaScript Arrays Reem Alattas
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScriptBryan Basham
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An IntroductionManvendra Singh
 

Viewers also liked (7)

JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]
 
LinkedIn TBC JavaScript 100: Functions
 LinkedIn TBC JavaScript 100: Functions LinkedIn TBC JavaScript 100: Functions
LinkedIn TBC JavaScript 100: Functions
 
JavaScript Arrays
JavaScript Arrays JavaScript Arrays
JavaScript Arrays
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
Javascript
JavascriptJavascript
Javascript
 

Similar to javascript arrays

Loops in C# for loops while and do while loop.
Loops in C# for loops while and do while loop.Loops in C# for loops while and do while loop.
Loops in C# for loops while and do while loop.Abid Kohistani
 
(2) collections algorithms
(2) collections algorithms(2) collections algorithms
(2) collections algorithmsNico Ludwig
 
Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Mohd Harris Ahmad Jaal
 
Object Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. ArrayObject Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. ArrayAndiNurkholis1
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and PointersMichael Heron
 
Array and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfArray and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfajajkhan16
 
Chapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdfChapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdfKirubelWondwoson1
 

Similar to javascript arrays (20)

Chapter-Five.pptx
Chapter-Five.pptxChapter-Five.pptx
Chapter-Five.pptx
 
Loops in C# for loops while and do while loop.
Loops in C# for loops while and do while loop.Loops in C# for loops while and do while loop.
Loops in C# for loops while and do while loop.
 
Python array
Python arrayPython array
Python array
 
(2) collections algorithms
(2) collections algorithms(2) collections algorithms
(2) collections algorithms
 
Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4
 
C# Array.pptx
C# Array.pptxC# Array.pptx
C# Array.pptx
 
Object Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. ArrayObject Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. Array
 
Arrays
ArraysArrays
Arrays
 
Array
ArrayArray
Array
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
Array and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfArray and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdf
 
Arrays
ArraysArrays
Arrays
 
Chapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdfChapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdf
 
2. array and numerical arrays
2. array and numerical arrays2. array and numerical arrays
2. array and numerical arrays
 
Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 
2 arrays
2   arrays2   arrays
2 arrays
 
javaarray
javaarrayjavaarray
javaarray
 
Arrays
ArraysArrays
Arrays
 

More from osman do

الامتحان الالكتروني
الامتحان الالكترونيالامتحان الالكتروني
الامتحان الالكترونيosman do
 
جافا سكريبت
جافا سكريبتجافا سكريبت
جافا سكريبتosman do
 
javascript3
javascript3javascript3
javascript3osman do
 
javascript2
javascript2javascript2
javascript2osman do
 
javascript 1
javascript 1javascript 1
javascript 1osman do
 
Php sessions
Php sessionsPhp sessions
Php sessionsosman do
 
Php database - 4
Php   database - 4Php   database - 4
Php database - 4osman do
 
Php database - 3
Php   database - 3Php   database - 3
Php database - 3osman do
 
Php database - 2
Php   database - 2Php   database - 2
Php database - 2osman do
 
Php database - 1
Php   database - 1Php   database - 1
Php database - 1osman do
 
مهارات المعلوماتية
مهارات المعلوماتيةمهارات المعلوماتية
مهارات المعلوماتيةosman do
 
عملي وسائط متعددة - جامعة أفريقيا العالمية
عملي وسائط متعددة - جامعة أفريقيا العالميةعملي وسائط متعددة - جامعة أفريقيا العالمية
عملي وسائط متعددة - جامعة أفريقيا العالميةosman do
 
جامعة أفريقيا العالمية - دورة مهارات العروض التقديمية
جامعة أفريقيا العالمية - دورة مهارات العروض التقديميةجامعة أفريقيا العالمية - دورة مهارات العروض التقديمية
جامعة أفريقيا العالمية - دورة مهارات العروض التقديميةosman do
 
Presentation tips Arabic
Presentation tips ArabicPresentation tips Arabic
Presentation tips Arabicosman do
 

More from osman do (15)

الامتحان الالكتروني
الامتحان الالكترونيالامتحان الالكتروني
الامتحان الالكتروني
 
جافا سكريبت
جافا سكريبتجافا سكريبت
جافا سكريبت
 
javascript3
javascript3javascript3
javascript3
 
javascript2
javascript2javascript2
javascript2
 
javascript 1
javascript 1javascript 1
javascript 1
 
Ia css
Ia  cssIa  css
Ia css
 
Php sessions
Php sessionsPhp sessions
Php sessions
 
Php database - 4
Php   database - 4Php   database - 4
Php database - 4
 
Php database - 3
Php   database - 3Php   database - 3
Php database - 3
 
Php database - 2
Php   database - 2Php   database - 2
Php database - 2
 
Php database - 1
Php   database - 1Php   database - 1
Php database - 1
 
مهارات المعلوماتية
مهارات المعلوماتيةمهارات المعلوماتية
مهارات المعلوماتية
 
عملي وسائط متعددة - جامعة أفريقيا العالمية
عملي وسائط متعددة - جامعة أفريقيا العالميةعملي وسائط متعددة - جامعة أفريقيا العالمية
عملي وسائط متعددة - جامعة أفريقيا العالمية
 
جامعة أفريقيا العالمية - دورة مهارات العروض التقديمية
جامعة أفريقيا العالمية - دورة مهارات العروض التقديميةجامعة أفريقيا العالمية - دورة مهارات العروض التقديمية
جامعة أفريقيا العالمية - دورة مهارات العروض التقديمية
 
Presentation tips Arabic
Presentation tips ArabicPresentation tips Arabic
Presentation tips Arabic
 

Recently uploaded

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 

javascript arrays

  • 2. Definition • An array is a special variable, which can hold more than one value at a time. • They are a place in memory that can store multiple values
  • 3. Creating an Array 1. Using an array literal - Syntax : var array-name = [item1, item2, ...]; - e.g: var cars = [“Toyota", "Volvo", "BMW"]; 2. Using the Keyword new: - e.g: var cars = new Array(" Toyota ", "Volvo", "BMW");
  • 4. Accessing arrray elements • We can can access array elements using array name and element index. • Arrays indexed by numbers beginning from 0 upward. • e.g: in the previous example if we want to change the second element, we use : cars[1] = “Tucson";
  • 5. Displaying array elements • To display array elements we go through the elements using for loop. • Here we know the number of the elements by using length attribute of the array. e.g: cars.length • e.g: for(var i=0;i<cars.length;i++) Document.write(cars[i]+”<br>”);
  • 6. Two dimensional arrays • They are array which their elements are also arrays. • To declare a 2D array: Var numbers=[[1,2,3],[4,5]]; • To change the value of 4 to 6: Numbers[1][0]=6;
  • 7. Cont… • To display the elements we use nested for loop. e.g: for(var i=0;i<numbers.length;i++) { for(var j=0;j<numbers[i].length;j++) { Document.write(numbers[i][j]+”<br>”); } }