Data Types in JavaScript Flashcards
This 64 bit format is used to store numbers in JS
IEEE-754
use this method to convert a number to string
.toString(base)
this is the value numbers pick if they overflow storage
Infinity
4 most used rounding functions
Math.round
Math.ceil
Math.floor
Math.trunc
does NaN equal itself?
No
character encoding of strings in JS
UTF-16
Strings are immutable in JS. True/False
True
In JS lowercase alphabets are greater than Uppercase alphabets
True
Names of codePoint methods
codePointAt() —> gives unicode value
fromCodePoint() —> gets unicode character from integer value
localeCompare is used to compare two ____?
strings
What does the at() function do in an array
it fetches the element at position i;
if i is negative, it counts backwards.
Arrays extend objects in JavaScript. True / False ?
True
It is possible to add non-numeric key in an array. True / False ?
True, this is an inconvenience as programmer needs to be alert.
The length property in array is the number of elements in the array. True or False ??
False, it is the largest numeric index + 1.
This is the fastest and easiest way to clear an array in JS.
arr.length = 0;
length once reduced, truncates the array, and cannot be reassigned to its initial value.
The splice method returns this ____
the list of removed elements.
Symbol.iterator is used for ____
making an object iterable in the for…of loop
the 7 main methods of map are
new Map() - create map;
map. set(key, value) - insert key, value pair in map
map. get(key) - get the value of key
map. has(key) - true if key exists; false otherwise
map. delete(key) - remove value by key
map. clear() - remove all elements of map
map. size() - returns count of elements in map
What is SameValueZero
It is the algorithm maps use to compare keys; it is like strict equality, but only NaN is equal to NaN.
Map preserves the order of insertion. True / False ?
True. Objects are the ones that do not store values in inserted order.
The six methods of set are
new Set(iterable);
set. add(value);
set. delete(value);
set. has(value);
set. clear();
set. size();
Reflect.ownKeys(obj) returns ___
all keys; even symbolic ones.
Object.getOwnPropertySymbols(obj) returns ___
only symbolic keys
strings are iterables is JavaScript. True / False ?
True