Javascript - The Array object
On May 30,2022 by Tom RoutleyThe Array object is one of the JavaScript core objects, allowing you to create and manipulate arrays.
Here is the syntax for creating an array:
var x = new Array(element1[, element2, ...]);
If no element is specified as a parameter, an empty array is created. Otherwise, it will be initialized with the values ??passed as parameters (element1,element2...).
The Array object has two characteristic properties: the input and length properties.
The following table describes the properties of the Array object.
property description constructor This property contains the constructor of the Array object. input This property allows you to search the array using a regular expression length This property contains the number of array elements. prototype Allows you to add custom properties to the object.
The following table describes the methods of the Array object.
Method description concat(array1, array2[, array3, ...]) This method allows to concatenate multiple arrays join(array) or Array.join() This method returns a string containing all the elements of the array. pop(array) or Array.pop() This method removes the last element of the array and returns its value. TArray.push(value1[, value2, ...]) This method sums up one or more elements of the array. Arraeverse() This method reverse the order of the elements in the array. Array.shift() This method removes the first element of the array. Array.slice() This method returns an array containing part of the elements of an array. Array.splice() This method adds / removes elements from an array. Array.sort() This method is used to sort the elements of an array.. Array.unshift(value1[, value2, ...]) This method returns the source code that has created the Array object. ArraoString() This method returns the string corresponding to the instruction that helped create the Array object. Array.unshift() This method allows to add one or more elements to the beginning of the table. Array.valueOf This method simply returns the value of the Array object to which it refers.
Original document published on CommentcaMarcheet
Article Recommendations
Latest articles
Popular Articles
Archives
- November 2024
- October 2024
- September 2024
- August 2024
- July 2024
- June 2024
- May 2024
- April 2024
- March 2024
- February 2024
- January 2024
- December 2023
- November 2023
- October 2023
- September 2023
- August 2023
- July 2023
- June 2023
- May 2023
- April 2023
- March 2023
- February 2023
- January 2023
- December 2022
- November 2022
- October 2022
- September 2022
- August 2022
- July 2022
- June 2022
- May 2022
- April 2022
- March 2022
- February 2022
- January 2022
- December 2021
- November 2021
- October 2021
- September 2021
- August 2021
- July 2021
- January 2021
Leave a Reply