β To iterate through each element in the array
β Perform a task on each element which returns a value
β Returns a new array with all returned values
β Not suitable if task doesn't return any value
β Array.prototype.reduce()
β Use Case
β To iterate through each element in the array
β Perform a task on each element which accumulates the previous returned value with current element to return a new value
β Example
β Sum of all items
β Max of all items
β Array.prototype.every()
β Use Case
β To iterate through elements in the array until a certain condition is not met
β The task performed on each element must return a boolean value
β Stops iterating when condition is not met. Hence, it's not suitable for skipping.
β To find the very first occurrence of a "substring" in the original string
β We can also mention from which index the occurrence should be checked
20. String.prototype.charAt()
β Use Case
β To fetch the character at a specific position of a string.
β The character fetched is in UTF-16 and returned as a string
ββ String.prototype.trim()
β Use Case
β To remove whitespace from both ends of a string
β To get the largest integer less than or, equals to the given number
ββ Math.random()
β Use Case
β To get a floating point pseudo random number in the range of 0 to less than 1
β It can be multiplied by any number to make a random number being generated in the range of 0 to less than that number
ββ setTimeout()
β Use Case
β To execute a function or, piece of code after a timer expires
β The code is executed only for once.
β It is an asynchronous function. It shouldn't be used where pausing of execution is intended.
ββ setInterval()
β Use Case
β To execute a function or, piece of code repeatedly with a fix time delay
β The code is ensured to be executed each time after the time delay. But not "exactly" after the time delay.