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

PPT
Css lecture notes
Santhiya Grace
 
PPTX
presentation in html,css,javascript
FaysalAhammed5
 
PPSX
Javascript variables and datatypes
Varun C M
 
PPTX
Css selectors
Parth Trivedi
 
PPT
Introduction to JavaScript
Andres Baravalle
 
PPTX
9. ES6 | Let And Const | TypeScript | JavaScript
pcnmtutorials
 
PDF
jQuery for beginners
Arulmurugan Rajaraman
 
Css lecture notes
Santhiya Grace
 
presentation in html,css,javascript
FaysalAhammed5
 
Javascript variables and datatypes
Varun C M
 
Css selectors
Parth Trivedi
 
Introduction to JavaScript
Andres Baravalle
 
9. ES6 | Let And Const | TypeScript | JavaScript
pcnmtutorials
 
jQuery for beginners
Arulmurugan Rajaraman
 

What's hot (20)

PDF
Html forms
eShikshak
 
PPTX
Core java complete ppt(note)
arvind pandey
 
PPTX
HTML Forms
Ravinder Kamboj
 
PPT
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
PPTX
css.ppt
bhasula
 
PPTX
CSS
DivyaKS12
 
PPTX
html-table
Dhirendra Chauhan
 
PDF
Methods in Java
Jussi Pohjolainen
 
PPT
JavaScript: Events Handling
Yuriy Bezgachnyuk
 
PPTX
Html form tag
shreyachougule
 
ODP
Datatype in JavaScript
Rajat Saxena
 
PDF
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
PPTX
Html ppt
Ruchi Kumari
 
PPT
Javascript arrays
Hassan Dar
 
PPTX
Class template
Kousalya M
 
PPTX
Servlets
ZainabNoorGul
 
PPTX
Bootstrap 5 ppt
Mallikarjuna G D
 
PPTX
Document Object Model (DOM)
GOPAL BASAK
 
PPT
JavaScript - Part-1
Jainul Musani
 
PPTX
CSS - Text Properties
hstryk
 
Html forms
eShikshak
 
Core java complete ppt(note)
arvind pandey
 
HTML Forms
Ravinder Kamboj
 
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
css.ppt
bhasula
 
html-table
Dhirendra Chauhan
 
Methods in Java
Jussi Pohjolainen
 
JavaScript: Events Handling
Yuriy Bezgachnyuk
 
Html form tag
shreyachougule
 
Datatype in JavaScript
Rajat Saxena
 
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
Html ppt
Ruchi Kumari
 
Javascript arrays
Hassan Dar
 
Class template
Kousalya M
 
Servlets
ZainabNoorGul
 
Bootstrap 5 ppt
Mallikarjuna G D
 
Document Object Model (DOM)
GOPAL BASAK
 
JavaScript - Part-1
Jainul Musani
 
CSS - Text Properties
hstryk
 
Ad

Viewers also liked (14)

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
 
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
 
Javascript
Manav Prasad
 
Ad

Similar to Javascript - Array - Creating Array (20)

PPT
Js objects
Charles Russell
 
PPTX
arrays and its types and examples of sorting reversing arrays.pptx
zulfeiquaar
 
PPTX
Java script arrays
Frayosh Wadia
 
PPTX
Java script arrays
Frayosh Wadia
 
PPSX
javascript arrays
osman do
 
PPTX
JavaScript.pptx
pramod599939
 
DOC
Array properties
Shravan Sharma
 
PPT
Javascript - Getting Good with Loop and Array
Firdaus Adib
 
PPT
Java Script ppt
Priya Goyal
 
PPTX
Learn java script
Mahmoud Asadi
 
PPTX
PHP Array very Easy Demo
Salman Memon
 
PPTX
Module 2 Javascript. Advanced concepts of javascript
BKReddy3
 
PPTX
FFW Gabrovo PMG - JavaScript 2
Toni Kolev
 
DOCX
What are arrays in java script
Miguel Silva Loureiro
 
PPTX
1-JAVA SCRIPT. servere-side applications vs client side applications
surajshreyans
 
PPTX
TechCBT: JavaScript Arrays in Depth
Tech CBT
 
PPTX
introduction to java scriptsfor sym.pptx
gayatridwahane
 
PPTX
Net (f#) array
DrRajeshreeKhande
 
PDF
JAVASCRIPT OBJECTS.pdf
cherop41618145
 
PPT
Lecture no 9.ppt operating system semester four
VaibhavBhagwat18
 
Js objects
Charles Russell
 
arrays and its types and examples of sorting reversing arrays.pptx
zulfeiquaar
 
Java script arrays
Frayosh Wadia
 
Java script arrays
Frayosh Wadia
 
javascript arrays
osman do
 
JavaScript.pptx
pramod599939
 
Array properties
Shravan Sharma
 
Javascript - Getting Good with Loop and Array
Firdaus Adib
 
Java Script ppt
Priya Goyal
 
Learn java script
Mahmoud Asadi
 
PHP Array very Easy Demo
Salman Memon
 
Module 2 Javascript. Advanced concepts of javascript
BKReddy3
 
FFW Gabrovo PMG - JavaScript 2
Toni Kolev
 
What are arrays in java script
Miguel Silva Loureiro
 
1-JAVA SCRIPT. servere-side applications vs client side applications
surajshreyans
 
TechCBT: JavaScript Arrays in Depth
Tech CBT
 
introduction to java scriptsfor sym.pptx
gayatridwahane
 
Net (f#) array
DrRajeshreeKhande
 
JAVASCRIPT OBJECTS.pdf
cherop41618145
 
Lecture no 9.ppt operating system semester four
VaibhavBhagwat18
 

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)

PDF
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
PPTX
Why Use Open Source Reporting Tools for Business Intelligence.pptx
Varsha Nayak
 
PDF
Solar Panel Installation Guide – Step By Step Process 2025.pdf
CRMLeaf
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PDF
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
QAware GmbH
 
PPTX
Services offered by Dynamic Solutions in Pakistan
DaniyaalAdeemShibli1
 
PDF
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
PPTX
oapresentation.pptx
mehatdhavalrajubhai
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PPTX
PFAS Reporting Requirements 2026 Are You Submission Ready Certivo.pptx
Certivo Inc
 
PPTX
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
PPTX
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
PDF
How to Seamlessly Integrate Salesforce Data Cloud with Marketing Cloud.pdf
NSIQINFOTECH
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
Why Use Open Source Reporting Tools for Business Intelligence.pptx
Varsha Nayak
 
Solar Panel Installation Guide – Step By Step Process 2025.pdf
CRMLeaf
 
Presentation about variables and constant.pptx
kr2589474
 
Activate_Methodology_Summary presentatio
annapureddyn
 
Presentation about variables and constant.pptx
safalsingh810
 
Key Features to Look for in Arizona App Development Services
Net-Craft.com
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
QAware GmbH
 
Services offered by Dynamic Solutions in Pakistan
DaniyaalAdeemShibli1
 
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
oapresentation.pptx
mehatdhavalrajubhai
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PFAS Reporting Requirements 2026 Are You Submission Ready Certivo.pptx
Certivo Inc
 
Maximizing Revenue with Marketo Measure: A Deep Dive into Multi-Touch Attribu...
bbedford2
 
ConcordeApp: Engineering Global Impact & Unlocking Billions in Event ROI with AI
chastechaste14
 
How to Seamlessly Integrate Salesforce Data Cloud with Marketing Cloud.pdf
NSIQINFOTECH
 
Bandai Playdia The Book - David Glotz
BluePanther6
 

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