SlideShare a Scribd company logo
1 of 9
Array
Creating Arrays
Arrays
• The simplest way to create an array is by
declaring an array variable using the []
operator.
• var myArray = []
Arrays
• When you create an array in this manner, you
have an array with length of 0.
var myArray = []
console.log(myArray.length);
Arrays
• Another way to create an array is to declare an
array variable with a set of elements inside
the [] operator:
var myArray = [1,2,3,5,9,7,0,-1];
console.log(myArray.length);
Arrays
• You can also create an array by calling the
Array constructor:
var myArray = new Array();
console.log(myArray.length);
Array Constructor
Arrays
• You can call the Array constructor with a set of
elements as arguments to the constructor:
var myArray = new Array(8, 9, 11, 13,5,2);
console.log(myArray.length);
Arrays
• Finally, you can create an array by calling the
Array constructor with a single argument
specifying the length of the array:
var myArray = new Array(10);
console.log(myArray.length);
Arrays
• JavaScript array elements do not all have to be
of the same type:
var myArray = [‘5.2’, 38, “Samuel”, true, null];
console.log(myArray);
Arrays
• We can verify that an object is an array by
calling the Array.isArray() function, like this:
var myArray = [‘5.2’, 38];
var number = 66;
console.log(Array.isArray(myArray));
console.log(Array.isArray(number));

More Related Content

What's hot (20)

JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
Loops in java script
Loops in java scriptLoops in java script
Loops in java script
 
Css
CssCss
Css
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
 
Java script
Java scriptJava script
Java script
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
Javascript functions
Javascript functionsJavascript functions
Javascript functions
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Bootstrap PPT by Mukesh
Bootstrap PPT by MukeshBootstrap PPT by Mukesh
Bootstrap PPT by Mukesh
 
3.2 javascript regex
3.2 javascript regex3.2 javascript regex
3.2 javascript regex
 
Java script ppt
Java script pptJava script ppt
Java script ppt
 
Dom
DomDom
Dom
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
 
Java script
Java scriptJava script
Java script
 

Viewers also liked

Viewers also liked (13)

Javascript
JavascriptJavascript
Javascript
 
JavaScript, VBScript, AJAX, CGI
JavaScript, VBScript, AJAX, CGIJavaScript, VBScript, AJAX, CGI
JavaScript, VBScript, AJAX, CGI
 
JavaScript Arrays
JavaScript Arrays JavaScript Arrays
JavaScript Arrays
 
Arrays and Functions in JavaScript
Arrays and Functions in JavaScriptArrays and Functions in JavaScript
Arrays and Functions in JavaScript
 
CSS
CSSCSS
CSS
 
How to Create an Array & types in PHP
How to Create an Array & types in PHP How to Create an Array & types in PHP
How to Create an Array & types in PHP
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Print CSS
Print CSSPrint CSS
Print CSS
 
Javascript by geetanjali
Javascript by geetanjaliJavascript by geetanjali
Javascript by geetanjali
 
Javascript (parte 1)
Javascript (parte 1)Javascript (parte 1)
Javascript (parte 1)
 
Ecommerce final
Ecommerce finalEcommerce final
Ecommerce final
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in java
 
Js ppt
Js pptJs ppt
Js ppt
 

Similar to Javascript - Array - Creating Array

Lec 1.5 Object Oriented Programming
Lec 1.5 Object Oriented ProgrammingLec 1.5 Object Oriented Programming
Lec 1.5 Object Oriented ProgrammingBadar Waseer
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injavairdginfo
 
arrays in c# including Classes handling arrays
arrays in c#  including Classes handling arraysarrays in c#  including Classes handling arrays
arrays in c# including Classes handling arraysJayanthiM19
 
CHAPTER-5.ppt
CHAPTER-5.pptCHAPTER-5.ppt
CHAPTER-5.pptTekle12
 
Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)Talha mahmood
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfinfo309708
 
Array and Collections in c#
Array and Collections in c#Array and Collections in c#
Array and Collections in c#Umar Farooq
 

Similar to Javascript - Array - Creating Array (20)

Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Arrays
ArraysArrays
Arrays
 
Python array
Python arrayPython array
Python array
 
Array
ArrayArray
Array
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Lec 1.5 Object Oriented Programming
Lec 1.5 Object Oriented ProgrammingLec 1.5 Object Oriented Programming
Lec 1.5 Object Oriented Programming
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injava
 
arrays in c# including Classes handling arrays
arrays in c#  including Classes handling arraysarrays in c#  including Classes handling arrays
arrays in c# including Classes handling arrays
 
Basics of array.pptx
Basics of array.pptxBasics of array.pptx
Basics of array.pptx
 
CHAPTER-5.ppt
CHAPTER-5.pptCHAPTER-5.ppt
CHAPTER-5.ppt
 
Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)Arrays in java (signle dimensional array)
Arrays in java (signle dimensional array)
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
 
Array and Collections in c#
Array and Collections in c#Array and Collections in c#
Array and Collections in c#
 
Array-part1
Array-part1Array-part1
Array-part1
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
 
Arrays
ArraysArrays
Arrays
 
2 Arrays & Strings.pptx
2 Arrays & Strings.pptx2 Arrays & Strings.pptx
2 Arrays & Strings.pptx
 
Md05 arrays
Md05 arraysMd05 arrays
Md05 arrays
 
Array
ArrayArray
Array
 

More from Samuel Santos

Javascript Canvas API
Javascript Canvas APIJavascript Canvas API
Javascript Canvas APISamuel Santos
 
Javascript - Numbers
Javascript   - NumbersJavascript   - Numbers
Javascript - NumbersSamuel Santos
 
Javascript - Arrays - mutator functions
Javascript  - Arrays - mutator functionsJavascript  - Arrays - mutator functions
Javascript - Arrays - mutator functionsSamuel Santos
 
Javascript - Arrays - accessor functions
Javascript   - Arrays - accessor functionsJavascript   - Arrays - accessor functions
Javascript - Arrays - accessor functionsSamuel Santos
 
Javascript - Array - Writing
Javascript - Array - WritingJavascript - Array - Writing
Javascript - Array - WritingSamuel Santos
 
Javascript - Arithmetic in Javascript
Javascript - Arithmetic in JavascriptJavascript - Arithmetic in Javascript
Javascript - Arithmetic in JavascriptSamuel Santos
 
Javascript ADT - List
Javascript   ADT - ListJavascript   ADT - List
Javascript ADT - ListSamuel Santos
 
Javascript - ADT - List - Implementation
Javascript - ADT -  List - ImplementationJavascript - ADT -  List - Implementation
Javascript - ADT - List - ImplementationSamuel Santos
 

More from Samuel Santos (11)

Javascript stack
Javascript   stackJavascript   stack
Javascript stack
 
Javascript Canvas API
Javascript Canvas APIJavascript Canvas API
Javascript Canvas API
 
Javascript - Numbers
Javascript   - NumbersJavascript   - Numbers
Javascript - Numbers
 
Javascript - Arrays - mutator functions
Javascript  - Arrays - mutator functionsJavascript  - Arrays - mutator functions
Javascript - Arrays - mutator functions
 
Javascript - Arrays - accessor functions
Javascript   - Arrays - accessor functionsJavascript   - Arrays - accessor functions
Javascript - Arrays - accessor functions
 
Javascript - Array - Writing
Javascript - Array - WritingJavascript - Array - Writing
Javascript - Array - Writing
 
Javascript - Arithmetic in Javascript
Javascript - Arithmetic in JavascriptJavascript - Arithmetic in Javascript
Javascript - Arithmetic in Javascript
 
Javascript ADT - List
Javascript   ADT - ListJavascript   ADT - List
Javascript ADT - List
 
Javascript - ADT - List - Implementation
Javascript - ADT -  List - ImplementationJavascript - ADT -  List - Implementation
Javascript - ADT - List - Implementation
 
Variables
VariablesVariables
Variables
 
Java Stack (Pilha)
Java Stack (Pilha)Java Stack (Pilha)
Java Stack (Pilha)
 

Recently uploaded

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 

Javascript - Array - Creating Array

  • 2. Arrays • The simplest way to create an array is by declaring an array variable using the [] operator. • var myArray = []
  • 3. Arrays • When you create an array in this manner, you have an array with length of 0. var myArray = [] console.log(myArray.length);
  • 4. Arrays • Another way to create an array is to declare an array variable with a set of elements inside the [] operator: var myArray = [1,2,3,5,9,7,0,-1]; console.log(myArray.length);
  • 5. Arrays • You can also create an array by calling the Array constructor: var myArray = new Array(); console.log(myArray.length); Array Constructor
  • 6. Arrays • You can call the Array constructor with a set of elements as arguments to the constructor: var myArray = new Array(8, 9, 11, 13,5,2); console.log(myArray.length);
  • 7. Arrays • Finally, you can create an array by calling the Array constructor with a single argument specifying the length of the array: var myArray = new Array(10); console.log(myArray.length);
  • 8. Arrays • JavaScript array elements do not all have to be of the same type: var myArray = [‘5.2’, 38, “Samuel”, true, null]; console.log(myArray);
  • 9. Arrays • We can verify that an object is an array by calling the Array.isArray() function, like this: var myArray = [‘5.2’, 38]; var number = 66; console.log(Array.isArray(myArray)); console.log(Array.isArray(number));