Commonly Utilized JavaScript Methods Part IIII - TypedArray, Map, and Set
Welcome back to the series, this article is covering objects/structures - TypedArray, Map and Set.
What is a TypedArray?
It is a data structure that hosts specific elements types in the confines of an array. The various element types that are associated with TypedArrays are 9:
1. Int8Array utilized to store byte type elements/integers ranging
from -128-127.
2. Unit8Array utilized to store octet type elements/integers ranging
from 0 to 255.
3. Unit8ClampedArray utilized to store octet type elements/integers ranging
from 0 to 255 but they differ from Unit8Array - due to it being clamped.
4. Int16Array utilized to store long type elements/integers ranging
from -32668-32767.
5.Unit16Array utilized to store unsigned short type elements/integers
ranging from 0 to 65535.
6. Int32Array utilized to store long types as well with 32-bit signed integers
ranging from -2147483648-214786347.
7. Uint32Array utilized to store unsigned long types with 32-bit unsigned integers
ranging from 0-4294967295.
8. Float32Array utilized to store 32-bit floating point numbers, and unrestricted float
types ranging from 1.2x1.0(to the power of 38)-3.4x10(to the power of 38).
9. Float64Array utilize to store 64-bit floating point numbers, and unrestricted doubles
ranging from 5.0x10324 to 1.8x10308.
Methods associated with typedArray methods include:
copywithin() - copying a portion of an array to another location
inside the same array and return the size of the array.
entries() - utilized to obtain key-value pairs of each index in array.
every() - checks whether all the elements satisfy condition appended.
fill() - appends values to every element in array.
filter() - Forms a new array under conditions passed.
find() - obtain value of first element that passes conditioned appended.
for of loop.
Example of Typed Array with For Of Loop:
What is Map?
Map is essentially an object that retains the key-value pairs of elements that can appended via .set(), retrieved via .get(), removal via .delete(), conditions via .has() and volume is determined via size(). Map is created via a constructor which results to the appending of key and values pairs for the programmers dispense.
Examples of Map:
What is Set?
Set is an object which enables programmers to store any values as well as primitive values - which is string,
number, boolean, undefined, symbol and null although primitive values can't altered. Set like Map is invoked via a constructor, and has methods to add, delete and check volume as well. You can also iterate through sets as displayed in for of loop.
Example of Creating A Set:
This concludes my article, next topic shall be about Recursive functions.
Comments
Post a Comment