Array (Array) in JavaScript
Array object - Array helps you store multiple values in a single variable. It stores a set of fixed-size ranges of elements in the same type (type). An array is used to store a data set, but it is often more useful to think of an array as a collection of variables in the same type.
Syntax
Use the following syntax to create an Array object:
var fruits = new Array ( "apple" , "orange" , "mango" );
The Array parameter is a list of strings or integers. When you define a single numeric parameter with the Array constructor, you specify the initialization length of the array. The maximum permitted length for an array is 4,294,967,295.
You can create an array by simply assigning the following values:
var fruits = [ "apple" , "orange" , "mango" ];
You will use the sequence number to access and set the values inside an array as follows:
fruits [ 0 ] is the first element fruits [ 1 ] is the second element fruits [ 2 ] is the third element
Array properties
Here are the properties of the Array object and their description.
Properties Descriptionconstructor
Returns a reference to the array function that creates that object. index The property represents the zero-based index of the match in the string. input This attribute is present only in arrays created by regular Expression matches.length
Reflect the number of elements in an array.prototype
The prototype property allows you to add properties and methods to an object.Array methods
Below is a list of the methods of the Array object along with their description.
Method Descriptionconcat ()
Returns a new array that includes this array in combination with other arrays and / or values.every ()
Returns true if each element in this array satisfies the given test function.filter ()
Create a new array with all elements of this array, for which the filter function returns true.forEach ()
Call a function for each element in the array.indexOf ()
Returns the first (lowest) index of an element in the array equivalent to the given value, or -1 if not found.join ()
Combine all elements in an array into a string.lastIndexOf ()
Returns the last (largest) index of an element in the array equivalent to the given value, or -1 if not found.map ()
Create a new array with the results of calling a given function on each element of this array.pop ()
Remove the last element from an array and return that element.push ()
Add one or more elements to the end of an array and return the new length of the array.reduce ()
Apply a function simultaneously with two values of the array (from left to right) when reducing it to a single value.reduceRight ()
Apply a function simultaneously with two values of the array (from right to left) when it is reduced to a single value.reverse ()
Reverse the order of the elements of an array - First become the last and finally become the first.shift ()
Remove the first element from an array and return that element.slice ()
Extract - extract an area of an array and return a new array.some ()
Returns true if at least one element in this array satisfies the given test function.toSource ()
Represents the source code of an object.sort ()
Arrange the elements of an array.splice ()
Add and / or remove elements from an array.toString ()
Returns a string representing the array and its elements.unshift ()
Add one or more elements to the beginning of an array and return the new length of the array.According to Tutorialspoint
Previous article: String object in JavaScript
Next lesson: Date object in JavaScript
You should read it
May be interested
- Top site with many good JavaScript exercises to practicemany people, after taking javascript courses and being equipped with some knowledge of the language they pursue, are eager to improve and cultivate these learned skills. so this article will give you a list of the top 3 websites to actually make javascript.
- What is JavaScript?javascript is a programming language of html and web. it is lightweight and most commonly used as part of web pages, but their implementation allows client-side scripts to interact with users and create dynamic websites. it is an interpreted programming language with object-oriented capabilities.
- Multimedia (Multimedia) in JavaScriptthe navigator object in javascript includes a child object called plugins. this object is an array, with an entry for each plug-in installed in the browser. the navigator.plugins object is only supported by netscape, firefox and mozilla.
- ! = and! == What is the difference in JavaScript?javascript includes operators like in other languages. an operator performs some operations on one or more operands (data values) and produces a result. today's article will help readers learn about 2! = and! == operators in javascript.
- Learn about ES6 in Javascriptes6 refers to version 6 of the ecma script programming language. ecma script is the standard name for javascript and version 6 is the next version after version 5, released in 2011.
- Array in Language Cthe c programming language provides a data structure called an array, stored in a set of data of the same type with fixed length. an array is used to store data sets, but it is useful if you think of an array of variables with the same type.
- How to copy one array into another array in Golangin go, an array is a fixed-length sequence containing elements of a specific type. copying one array to another is simple but requires both arrays to be of the same length and type.
- Summary of JavaScript exercises with sample codein order to make your javascript learning easier, tipsmake.com has compiled a number of javascript exercises with sample solutions for you to practice.
- JavaScript location in HTML Filethere is flexibility in providing javascript code anywhere in an html document. however, the most preferred ways to include javascript in an html file.
- How to Turn on JavaScriptjavascript is a language used in many websites to provide additional functionality and access to the user. developers use javascript to deliver a large part of their site's functionality to you, the user. your browser must have javascript...