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

PPTX
Java script
PPT
JavaScript - An Introduction
PDF
Nodejs presentation
PPTX
What is CSS?
PPTX
jQuery
PPTX
HTML5 & CSS3
PPT
Introduction to CSS Borders - Lesson 4
Java script
JavaScript - An Introduction
Nodejs presentation
What is CSS?
jQuery
HTML5 & CSS3
Introduction to CSS Borders - Lesson 4

What's hot (20)

PPTX
Java script
PDF
Basics of JavaScript
PPTX
Html5 and-css3-overview
PPTX
PPTX
Nodejs functions & modules
PPTX
Javascript
PDF
CSS Day: CSS Grid Layout
PPT
cascading style sheet ppt
PDF
CSS3 Media Queries
PPTX
Mern stack developement
PDF
JavaScript Interview Questions with Answers
PPTX
Java script
PPTX
Ajax
PPT
Html & Css presentation
PPT
Cascading Style Sheets (CSS) help
PPTX
Html and css
PPTX
Lab #2: Introduction to Javascript
PPTX
Java script errors & exceptions handling
Java script
Basics of JavaScript
Html5 and-css3-overview
Nodejs functions & modules
Javascript
CSS Day: CSS Grid Layout
cascading style sheet ppt
CSS3 Media Queries
Mern stack developement
JavaScript Interview Questions with Answers
Java script
Ajax
Html & Css presentation
Cascading Style Sheets (CSS) help
Html and css
Lab #2: Introduction to Javascript
Java script errors & exceptions handling
Ad

Viewers also liked (16)

PPT
Javascript arrays
PPT
Javascript
PPTX
JavaScript, VBScript, AJAX, CGI
PPT
JavaScript Arrays
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
JavaScript Arrays
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)

PPTX
Arrays in java
PPT
Arrays
PPTX
Python array
PPT
Array
DOCX
Chapter 4
PPTX
Lec 1.5 Object Oriented Programming
PPTX
6 arrays injava
PPTX
arrays in c# including Classes handling arrays
PPTX
Basics of array.pptx
PPT
CHAPTER-5.ppt
PPTX
numpydocococ34554367827839271966666.pptx
PPTX
Arrays in java (signle dimensional array)
PDF
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
PDF
Array and Collections in c#
PDF
Array-part1
PPTX
Array.pptx
PDF
PPTX
2 Arrays & Strings.pptx
PPT
Md05 arrays
PPTX
Arrays in java
Arrays
Python array
Array
Chapter 4
Lec 1.5 Object Oriented Programming
6 arrays injava
arrays in c# including Classes handling arrays
Basics of array.pptx
CHAPTER-5.ppt
numpydocococ34554367827839271966666.pptx
Arrays in java (signle dimensional array)
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Array and Collections in c#
Array-part1
Array.pptx
2 Arrays & Strings.pptx
Md05 arrays

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
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Transform Your Business with a Software ERP System
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
ai tools demonstartion for schools and inter college
PPTX
Introduction to Artificial Intelligence
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Nekopoi APK 2025 free lastest update
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
assetexplorer- product-overview - presentation
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
L1 - Introduction to python Backend.pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
history of c programming in notes for students .pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Transform Your Business with a Software ERP System
Navsoft: AI-Powered Business Solutions & Custom Software Development
ai tools demonstartion for schools and inter college
Introduction to Artificial Intelligence
Wondershare Filmora 15 Crack With Activation Key [2025
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
How to Choose the Right IT Partner for Your Business in Malaysia
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Nekopoi APK 2025 free lastest update
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
assetexplorer- product-overview - presentation
Digital Systems & Binary Numbers (comprehensive )
VVF-Customer-Presentation2025-Ver1.9.pptx
L1 - Introduction to python Backend.pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Design an Analysis of Algorithms I-SECS-1021-03
Designing Intelligence for the Shop Floor.pdf
history of c programming in notes for students .pptx

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