JavaScript typedArray.filter() with Example Last Updated : 22 Dec, 2022 Comments Improve Suggest changes Like Article Like Report The Javascript typedArray.filter() is an inbuilt function in javascript that is used to form a new typedArray with the elements which satisfy the test implemented by the function provided. Syntax: typedarray.filter(callback) Parameters: It takes the parameter "callback" function which checks each element of the typedArray satisfied by the condition provided. The callback function takes three parameters that are specified below- element: It is the value of the element.index: It is the index of the element.array: It is the array that is being traversed. Return value: It returns a new typedarray with the elements that satisfy the test. JavaScript example to show the working of this function: Example 1: This example shows the use of the typedArray.filter() method in Javascript. javascript <script> // Calling isNegative function to check // elements of the typedArray function isNegative(element, index, array) { return element < 0; } // Created some typedArrays. const A = new Int8Array([ -10, 20, -30, 40, -50 ]); const B = new Int8Array([ 10, 20, -30, 40, -50 ]); const C = new Int8Array([ -10, 20, -30, 40, 50 ]); const D = new Int8Array([ -10, 20, 30, 40, -50 ]); // Calling filter() function to check condition // provided by its parameter const a = A.filter(isNegative); const b = B.filter(isNegative); const c = C.filter(isNegative); const d = D.filter(isNegative); // Printing the filtered typedArray console.log(a); console.log(b); console.log(c); console.log(d); </script> Output: -10,-30,-50 -30,-50 -10,-30 -10,-50 Create Quiz Comment S ShivamKD Follow 0 Improve S ShivamKD Follow 0 Improve Article Tags : JavaScript Web Technologies javascript-functions javascript-typedArray Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)8 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like