ES6 | Array filter() Method Last Updated : 28 May, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The Array filter() is an inbuilt method, this method creates a new array with elements that follow or pass the given criteria and condition. Few Examples have been implemented below for a better understanding of the concept Syntax: var newArray = arr.filter(callback(element[, index[, array]]) [, thisArg]) Parameter: This method accepts 2 parameters which was mentioned above and described below: Callback: The function is a predicate, to test each element of the array. Return true to keep the element, false otherwise. It accepts three arguments:element: The current element being processed in the array.index(Optional): The index of the current element being processed in the array.array(Optional): The array filter was called upon.thisArg(Optional): Value to use as this when executing the callback. Example 1: The filter function filters all the numeric values in the array greater than 5 javascript var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var result = numbers.filter(number => number > 5); console.log(result); Output : [ 6, 7, 8, 9, 10 ] Time complexity: O(n) Auxiliary Space: O(1) Example 2: The filter function filters all the words in the array which have length greater than 5 javascript var words = ["hi", "hello", "hey", "apple", "watermelon", "lemon", "javascript"]; var result = words.filter(word => word.length > 5); console.log(result); Output : [ 'watermelon', 'javascript' ] Time complexity: O(n) Auxiliary Space: O(1) Example 3: The filter function filters all invalid id of users from the array. javascript var jsonarr = [ { id: 1, name: "joe" }, { id: -19, name: "john" }, { id: 20, name: "james" }, { id: 25, name: "jack" }, { id: -10, name: "joseph" }, { id: "not a number", name: "jimmy" }, { id: null, name: "jeff" }, ] var result = jsonarr.filter(user => user.id > 0); console.log(result); Output: [{"id":1,"name":"joe"},{"id":20,"name":"james"}, {"id":25,"name":"jack"}] Time complexity: O(n) Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article ES6 | Array filter() Method I IshjotSingh97 Follow Improve Article Tags : Technical Scripter JavaScript Web Technologies Technical Scripter 2019 JavaScript-ES +1 More Similar Reads Array Helper Methods in ES6 Array helper methods in ES6 (JavaScript) are extremely useful for working with data stored in arrays. As a web developer, you often work with arrays, whether they contain simple numbers or complex objects with many attributes. These methods significantly simplify the manipulation of arrays, making i 3 min read Ember.js ArrayProxy filter() Method Ember.js is an open-source JavaScript framework used for developing large client-side web applications which is based on Model-View-Controller (MVC) architecture. Ember.js is one of the most widely used front-end application frameworks. It is made to speed up development and increase productivity. C 4 min read JavaScript Array filter() Method The filter() method creates a new array containing elements that satisfy a specified condition. This method skips empty elements and does not change the original array.Create a new array consisting of only those elements that satisfy the condition checked by canVote() function.JavaScript// JavaScrip 3 min read Array filter() Method - TypeScript The Array.filter() method in TypeScript creates a new array with elements that pass the test provided by a callback function. It does not modify the original array and accepts an optional thisObject for context within the callback function.Syntaxarray.filter(callback[, thisObject])Parameter: This me 3 min read Ember.js ArrayProxy filterBy() Method Ember.js is an open-source JavaScript framework used for developing large client-side web applications which is based on Model-View-Controller (MVC) architecture. Ember.js is one of the most widely used front-end application frameworks. It is made to speed up development and increase productivity. C 4 min read Like