
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create an array of integers in JavaScript?
To create an array of integers in JavaScript, try the following −
var rank = [1, 2, 3, 4];
You can also use the new keyword to create array of integers in JavaScript −
var rank = new Array(1, 2, 3, 4);
The Array parameter is a list of strings or integers. When you specify a single numeric parameter with the Array constructor, you specify the initial length of the array. The maximum length allowed for an array is 4,294,967,295.
Example
Let’s see an example to create an array of integers in JavaScript −
<html> <body> <script> var arr1 = [50,60,65,90]; var arr2 = [25,35,50,90]; for (i = 0; i < arr1.length; i++) { for (z = 0; z < arr1.length; z++) { if (arr1[i] === arr2[z]) { document.write("<br>Matched element: "+arr2[z]); } } } </script> </body> </html>
Output
Matched element: 50 Matched element: 90
- Related Questions & Answers
- How to sort an array of integers correctly JavaScript?
- How to sort an array of integers correctly in JavaScript?
- Take an array of integers and create an array of all the possible permutations in JavaScript
- Inverting signs of integers in an array using JavaScript
- How to create an array of strings in JavaScript?
- Returning reverse array of integers using JavaScript
- How to create a dynamic array of integers in C++ using the new keyword
- How to iterate efficiently through an array of integers of unknown size in C#
- Finding the largest and smallest number in an unsorted array of integers in JavaScript
- How to create an array of Object in Java
- How to dynamically create radio buttons using an array in JavaScript?
- How to convert string to array of integers in java?
- Given an array of integers return positives, whose equivalent negatives present in it in JavaScript
- How to create an Array in Java?
- How to create an array in PowerShell?
Advertisements