C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript TypedArray filter() MethodThe filter() method creates a new array with all elements that pass the test implemented by the provided function. This method fills all the elements of an array from a start index to an end index with a static value. The filter() method does not apply the function for array elements without values. Syntax:array.filter (function (currentValue, index, arr), this_arg) Parameters:CurrentValue (required): The value of the current element. Return value:An array containing all the elements that pass the test. If no elements pass the test it returns an empty array. Browser Support:
ExampleJavaScript Array filter() Method <script type="text/javascript"> //JavaScript to illustrate filter() method function JavaTpoint(value) { return value>=5; } // Input array var arr= [1,2,3,4,5,6,7,8,9,10]; var result=arr.filter(JavaTpoint); document.write(result); // expected output: arr[Output: 5,6,7,8,9,10] </script> Output: 5,6,7,8,9,10
Next TopicJavaScript TypedArray Object
|