public static EcmaValue Filter([This] EcmaValue thisValue, EcmaValue callback, EcmaValue thisArg) { TypedArray array = thisValue.GetUnderlyingObject <TypedArray>(); Guard.BufferNotDetached(array); Guard.ArgumentIsCallable(callback); List <EcmaValue> filtered = new List <EcmaValue>(); for (int i = 0, length = array.Length; i < length; i++) { EcmaValue value = array.GetValueFromBuffer(i); if (callback.Call(thisArg, value, i, thisValue)) { filtered.Add(value); } } TypedArray target = TypedArray.SpeciesCreate(array, filtered.Count); for (int i = 0; i < filtered.Count; i++) { target.SetOrThrow(i, filtered[i]); } return(target); }