Abstract
Rest
...args: any[]The args
parameter in the code snippet represents a rest parameter. It
allows the function to accept any number of arguments as an array. In this case, the args
parameter is used to pass any additional arguments to the _getIterator
method.
Time Complexity: O(n) Space Complexity: O(1)
The every
function checks if every element in a collection satisfies a given condition.
The predicate
parameter is a callback function that takes three arguments:
value
, key
, and index
. It should return a boolean value indicating whether the condition is
met for the current element in the iteration.
Optional
thisArg: anyThe thisArg
parameter is an optional argument that specifies the value
to be used as this
when executing the predicate
function. If thisArg
is provided, it will be
passed as the first argument to the predicate
function. If thisArg
is not provided
The every
method is returning a boolean value. It returns true
if every element in
the collection satisfies the provided predicate function, and false
otherwise.
Time Complexity: O(n) Space Complexity: O(1)
The find
function iterates over the entries of a collection and returns the first value for
which the callback function returns true.
The callback function that will be called for each entry in the collection. It takes three arguments: the value of the entry, the key of the entry, and the index of the entry in the collection. It should return a boolean value indicating whether the current entry matches the desired condition.
Optional
thisArg: anyThe thisArg
parameter is an optional argument that specifies the value
to be used as this
when executing the callbackfn
function. If thisArg
is provided, it will
be passed as the this
value to the callbackfn
function. If thisArg @returns The method
findreturns the value of the first element in the iterable that satisfies the provided callback function. If no element satisfies the callback function,
undefined` is
returned.
Time Complexity: O(n) Space Complexity: O(1)
The forEach
function iterates over each key-value pair in a collection and executes a callback
function for each pair.
The callback function that will be called for each element in the collection. It takes four parameters: the value of the current element, the key of the current element, the index of the current element, and the collection itself.
Optional
thisArg: anyThe thisArg
parameter is an optional argument that allows you to
specify the value of this
within the callback function. If thisArg
is provided, it will be
used as the this
value when calling the callback function. If thisArg
is not provided, `
Time Complexity: O(n) Space Complexity: O(1)
The get
function retrieves the value associated with a given key from a collection.
K (the type of the key) - This parameter represents the key that is being searched for in the collection.
The get
method returns the value associated with the specified key if it exists in the
collection, otherwise it returns undefined
.
Time Complexity: O(n) Space Complexity: O(1)
The function checks if a given key exists in a collection.
The parameter "key" is of type K, which means it can be any type. It represents the key that we want to check for existence in the data structure.
a boolean value. It returns true if the key is found in the collection, and false otherwise.
Time Complexity: O(n) Space Complexity: O(1)
The function checks if a given value exists in a collection.
The parameter "value" is the value that we want to check if it exists in the collection.
a boolean value, either true or false.
Time Complexity: O(n) Space Complexity: O(1)
The reduce
function iterates over key-value pairs and applies a callback function to each pair,
accumulating a single value.
The callback function that will be called for each element in the collection. It takes four arguments: the current accumulator value, the current value of the element, the key of the element, and the index of the element in the collection. It should return the updated accumulator value.
The initialValue
parameter is the initial value of the accumulator. It
is the value that will be used as the first argument to the callbackfn
function when reducing
the elements of the collection.
The reduce
method is returning the final value of the accumulator after iterating over
all the elements in the collection.
Time Complexity: O(n) Space Complexity: O(1)
The "some" function iterates over a collection and returns true if at least one element satisfies a given predicate.
The predicate
parameter is a callback function that takes three arguments:
value
, key
, and index
. It should return a boolean value indicating whether the condition is
met for the current element in the iteration.
Optional
thisArg: anyThe thisArg
parameter is an optional argument that specifies the value
to be used as the this
value when executing the predicate
function. If thisArg
is provided,
it will be passed as the first argument to the predicate
function. If thisArg
is
a boolean value. It returns true if the predicate function returns true for any pair in the collection, and false otherwise.
Time Complexity: O(n) Space Complexity: O(1)
The function is an implementation of the Symbol.iterator method that returns an iterable iterator.