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
Bootstrap Components Quick Overview
PPT
JavaScript Arrays
PPTX
Java beans
PDF
Java arrays
PPTX
Java Beans
PPT
Java awt
PPT
Java collections concept
PPTX
Arrays in java
Bootstrap Components Quick Overview
JavaScript Arrays
Java beans
Java arrays
Java Beans
Java awt
Java collections concept
Arrays in java

What's hot (20)

PDF
ITFT-Constants, variables and data types in java
PDF
Generics
PDF
Php array
PPT
Introduction to java beans
PPT
Java exception
PDF
Java Collections Tutorials
PPS
Wrapper class
PPT
Exception Handling in JAVA
PDF
input/ output in java
PPTX
JAVA AWT
PPTX
classes and objects in C++
ODP
OOP java
PPTX
String, string builder, string buffer
PPT
Php Using Arrays
PDF
Set methods in python
PDF
Asp.net state management
PPTX
PYTHON OBJECTS - Copy.pptx
PPT
14 file handling
 
ITFT-Constants, variables and data types in java
Generics
Php array
Introduction to java beans
Java exception
Java Collections Tutorials
Wrapper class
Exception Handling in JAVA
input/ output in java
JAVA AWT
classes and objects in C++
OOP java
String, string builder, string buffer
Php Using Arrays
Set methods in python
Asp.net state management
PYTHON OBJECTS - Copy.pptx
14 file handling
 
Ad

Viewers also liked (15)

PPT
Javascript arrays
PPT
Javascript
PPTX
JavaScript, VBScript, AJAX, CGI
PDF
Arrays and Functions in JavaScript
PPTX
How to Create an Array & types in PHP
PPTX
Cloud computing
PPT
Print CSS
PPT
Javascript by geetanjali
PDF
Javascript (parte 1)
PPT
Ecommerce final
PDF
Built in classes in java
PPT
Js ppt
PDF
Fundamental JavaScript [UTC, March 2014]
PPT
Javascript
Javascript arrays
Javascript
JavaScript, VBScript, AJAX, CGI
Arrays and Functions in JavaScript
How to Create an Array & types in PHP
Cloud computing
Print CSS
Javascript by geetanjali
Javascript (parte 1)
Ecommerce final
Built in classes in java
Js ppt
Fundamental JavaScript [UTC, March 2014]
Javascript
Ad

Similar to Javascript - Array - Creating Array (20)

PPT
Js objects
PPTX
arrays and its types and examples of sorting reversing arrays.pptx
PPTX
Java script arrays
PPTX
Java script arrays
PPSX
javascript arrays
PPTX
JavaScript.pptx
DOC
Array properties
PPT
Javascript - Getting Good with Loop and Array
PPT
Java Script ppt
PPTX
Learn java script
PPTX
PHP Array very Easy Demo
PPTX
Module 2 Javascript. Advanced concepts of javascript
PPTX
FFW Gabrovo PMG - JavaScript 2
DOCX
What are arrays in java script
PPTX
1-JAVA SCRIPT. servere-side applications vs client side applications
PPTX
TechCBT: JavaScript Arrays in Depth
PPTX
introduction to java scriptsfor sym.pptx
PPTX
Net (f#) array
PDF
JAVASCRIPT OBJECTS.pdf
PPT
Lecture no 9.ppt operating system semester four
Js objects
arrays and its types and examples of sorting reversing arrays.pptx
Java script arrays
Java script arrays
javascript arrays
JavaScript.pptx
Array properties
Javascript - Getting Good with Loop and Array
Java Script ppt
Learn java script
PHP Array very Easy Demo
Module 2 Javascript. Advanced concepts of javascript
FFW Gabrovo PMG - JavaScript 2
What are arrays in java script
1-JAVA SCRIPT. servere-side applications vs client side applications
TechCBT: JavaScript Arrays in Depth
introduction to java scriptsfor sym.pptx
Net (f#) array
JAVASCRIPT OBJECTS.pdf
Lecture no 9.ppt operating system semester four

More from Samuel Santos (11)

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

Recently uploaded (20)

PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
System and Network Administration Chapter 2
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
L1 - Introduction to python Backend.pptx
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
assetexplorer- product-overview - presentation
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Transform Your Business with a Software ERP System
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PTS Company Brochure 2025 (1).pdf.......
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Wondershare Filmora 15 Crack With Activation Key [2025
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Computer Software and OS of computer science of grade 11.pptx
System and Network Administration Chapter 2
Navsoft: AI-Powered Business Solutions & Custom Software Development
L1 - Introduction to python Backend.pptx
How to Choose the Right IT Partner for Your Business in Malaysia
assetexplorer- product-overview - presentation
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
wealthsignaloriginal-com-DS-text-... (1).pdf
Transform Your Business with a Software ERP System

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