2 min read

JavaScript Array Complete Reference

An array is an object that can store a collection of items. Arrays become really useful when you need to store large amounts of data of the same type.
JavaScript Array Complete Reference

Array is used to store multiple elements in a single variable. It is often used when we want to store a list of elements and access them by a single variable.

Unlike most languages where the array is a reference to the multiple variables, in JavaScript array is a single variable that stores multiple elements.

JavaScript Array methods are listed below:

JavaScript Array concat() Method

The arr.concat() method is used to merge two or more arrays together. This method does not alter the original arrays passed as arguments. For example:

var num1 = [11, 12, 13],

num2 = [14, 15, 16],

num3 = [17, 18, 19];

print(num1.concat(num2, num3));

output: [11,12,13,14,15,16,17,18,19]

JavaScript Array filter() Method

The arr.filter() method is used to create a new array from a given array consisting of only those elements from the given array which satisfy a condition set by the argument method.

<script>
    // JavaScript to illustrate findIndex() method
    function canVote(age) {
        return age >= 18;
    }
  
    function func() {
        var filtered = [24, 33, 16, 40].filter(canVote);
        document.write(filtered);
    }
    func();
</script>                    
  • Output: [24,33,40]

Read More...

JavaScript Array Complete Reference - GeeksforGeeks
A computer science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
https://www.geeksforgeeks.org/javascript-array-complete-reference/

#Javascript #Arrays #Methods #Coding #Probyto #Probyto AI

Subscribe and follow us for latest news in Data Science and Machine learning and stay updated!
Facebook: https://facebook.com/probyto
Twitter: https://twitter.com/probyto
LinkedIn: https://linkedin.com/company/probyto
Instagram: https://instagram.com/probyto