SlideShare a Scribd company logo
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)

PPT
Java collections concept
kumar gaurav
 
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
PPTX
Ajax presentation
Bharat_Kumawat
 
PPTX
Java applets
Pihu Goel
 
PPTX
Methods in java
chauhankapil
 
PDF
Introduction to CSS3
Doris Chen
 
PPTX
Presentation of bootstrap
1amitgupta
 
PDF
Javascript basics
shreesenthil
 
PPTX
ArrayList in JAVA
SAGARDAVE29
 
PDF
Threads concept in java
Muthukumaran Subramanian
 
PPTX
Javascript 101
Shlomi Komemi
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
PPTX
Java constructors
QUONTRASOLUTIONS
 
PDF
GET and POST in PHP
Vineet Kumar Saini
 
PPT
Chap2 2 1
Hemo Chella
 
PPTX
Polymorphism in java
Janu Jahnavi
 
PDF
Internationalization
Ravi Kant Sahu
 
PDF
Spring boot jpa
Hamid Ghorbani
 
PDF
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
PDF
Introduction to web programming with JavaScript
T11 Sessions
 
Java collections concept
kumar gaurav
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Ajax presentation
Bharat_Kumawat
 
Java applets
Pihu Goel
 
Methods in java
chauhankapil
 
Introduction to CSS3
Doris Chen
 
Presentation of bootstrap
1amitgupta
 
Javascript basics
shreesenthil
 
ArrayList in JAVA
SAGARDAVE29
 
Threads concept in java
Muthukumaran Subramanian
 
Javascript 101
Shlomi Komemi
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Java constructors
QUONTRASOLUTIONS
 
GET and POST in PHP
Vineet Kumar Saini
 
Chap2 2 1
Hemo Chella
 
Polymorphism in java
Janu Jahnavi
 
Internationalization
Ravi Kant Sahu
 
Spring boot jpa
Hamid Ghorbani
 
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
Introduction to web programming with JavaScript
T11 Sessions
 

Viewers also liked (15)

PPT
Javascript
guest03a6e6
 
PPTX
JavaScript, VBScript, AJAX, CGI
Aashish Jain
 
PPT
JavaScript Arrays
Reem Alattas
 
PDF
Arrays and Functions in JavaScript
Михаил Петров
 
PPTX
How to Create an Array & types in PHP
Ajit Sinha
 
PPTX
Cloud computing
Ajit Sinha
 
PPT
Print CSS
Russ Weakley
 
PPT
Javascript by geetanjali
Geetanjali Bhosale
 
PDF
Javascript (parte 1)
Alex Camargo
 
PPT
Ecommerce final
Geetanjali Bhosale
 
PDF
Built in classes in java
Mahmoud Ali
 
PPT
Js ppt
Rakhi Thota
 
PDF
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
PPT
Javascript
Manav Prasad
 
Javascript
guest03a6e6
 
JavaScript, VBScript, AJAX, CGI
Aashish Jain
 
JavaScript Arrays
Reem Alattas
 
Arrays and Functions in JavaScript
Михаил Петров
 
How to Create an Array & types in PHP
Ajit Sinha
 
Cloud computing
Ajit Sinha
 
Print CSS
Russ Weakley
 
Javascript by geetanjali
Geetanjali Bhosale
 
Javascript (parte 1)
Alex Camargo
 
Ecommerce final
Geetanjali Bhosale
 
Built in classes in java
Mahmoud Ali
 
Js ppt
Rakhi Thota
 
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
Javascript
Manav Prasad
 
Ad

Similar to Javascript - Array - Creating Array (20)

PPTX
Arrays in java
bhavesh prakash
 
PPT
Arrays
swathi reddy
 
PPTX
Python array
Arnab Chakraborty
 
PPT
Array
PRN USM
 
DOCX
Chapter 4
Amrit Kaur
 
PPTX
Lec 1.5 Object Oriented Programming
Badar Waseer
 
PPTX
6 arrays injava
irdginfo
 
PPTX
arrays in c# including Classes handling arrays
JayanthiM19
 
PPTX
Basics of array.pptx
PRASENJITMORE2
 
PPT
CHAPTER-5.ppt
Tekle12
 
PPTX
Arrays in java (signle dimensional array)
Talha mahmood
 
PDF
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
info309708
 
PDF
Array and Collections in c#
Umar Farooq
 
PDF
Array-part1
AbishaiAsir
 
PPTX
Array.pptx
fixocin377
 
PDF
Arrays
Steven Wallach
 
PPTX
2 Arrays & Strings.pptx
aarockiaabinsAPIICSE
 
PPT
Md05 arrays
Rakesh Madugula
 
PPTX
Array
HarshKumar943076
 
PPTX
Programming in c arrays
Uma mohan
 
Arrays in java
bhavesh prakash
 
Arrays
swathi reddy
 
Python array
Arnab Chakraborty
 
Array
PRN USM
 
Chapter 4
Amrit Kaur
 
Lec 1.5 Object Oriented Programming
Badar Waseer
 
6 arrays injava
irdginfo
 
arrays in c# including Classes handling arrays
JayanthiM19
 
Basics of array.pptx
PRASENJITMORE2
 
CHAPTER-5.ppt
Tekle12
 
Arrays in java (signle dimensional array)
Talha mahmood
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
info309708
 
Array and Collections in c#
Umar Farooq
 
Array-part1
AbishaiAsir
 
Array.pptx
fixocin377
 
2 Arrays & Strings.pptx
aarockiaabinsAPIICSE
 
Md05 arrays
Rakesh Madugula
 
Programming in c arrays
Uma mohan
 
Ad

More from Samuel Santos (11)

PPTX
Javascript stack
Samuel Santos
 
PPTX
Javascript Canvas API
Samuel Santos
 
PPTX
Javascript - Numbers
Samuel Santos
 
PPTX
Javascript - Arrays - mutator functions
Samuel Santos
 
PPTX
Javascript - Arrays - accessor functions
Samuel Santos
 
PPTX
Javascript - Array - Writing
Samuel Santos
 
PPTX
Javascript - Arithmetic in Javascript
Samuel Santos
 
PPTX
Javascript ADT - List
Samuel Santos
 
PPTX
Javascript - ADT - List - Implementation
Samuel Santos
 
PPTX
Variables
Samuel Santos
 
PPTX
Java Stack (Pilha)
Samuel Santos
 
Javascript stack
Samuel Santos
 
Javascript Canvas API
Samuel Santos
 
Javascript - Numbers
Samuel Santos
 
Javascript - Arrays - mutator functions
Samuel Santos
 
Javascript - Arrays - accessor functions
Samuel Santos
 
Javascript - Array - Writing
Samuel Santos
 
Javascript - Arithmetic in Javascript
Samuel Santos
 
Javascript ADT - List
Samuel Santos
 
Javascript - ADT - List - Implementation
Samuel Santos
 
Variables
Samuel Santos
 
Java Stack (Pilha)
Samuel Santos
 

Recently uploaded (20)

PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 

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));