Javascript Flashcards
(92 cards)
array.forEach
Executes a provided function once for each array element
array.map
Creates a new array with the results of calling a provided function on every element in the calling array.
array.filter
Creates a new array with all elements that pass the test implemented by the provided function
array.find
Returns the first element in the array that satisfies the provided testing function
array.findIndex
Returns the index of the first element in the array that satisfies the provided testing function
array.some
Checks if at least one element in the array passes the test implemented by the provided function.
array.every
Checks if all elements in the array pass the test implemented by the provided function.
array.reduce
Executes a reducer function on each element of the array, resulting in a single output value.
array.reduceRight
Same as reduce, but processes the array from right to left.
array.sort
Sorts the elements of an array in place and returns the sorted array.
array.slice
Returns a shallow copy of a portion of an array into a new array object.
array.splice
Changes the contents of an array by removing or replacing existing elements and/or adding new elements in place.
array.concat
Returns a new array comprised of this array joined with other array(s) and/or value(s).
array.includes
Determines whether an array includes a certain element, returning true or false as appropriate.
array.indexOf
Returns the first index at which a given element can be found in the array, or -1 if it is not present.
array.lastIndexOf
Returns the last index at which a given element can be found in the array, or -1 if it is not present.
array.join
joins all elements of an array into a string.
isArray
Determines whether the passed value is an Array
array.toString
Returns a string representing the specified array and its elements.
array.reverse
Reverses the elements of an array in place.
Primitive Data Types
Stored directly in the variable’s location: Primitive data types are stored directly in the variable’s memory location.
Immutable: Once a primitive value is assigned to a variable, its value cannot be changed. Any operation that appears to modify a primitive value actually creates a new value.
Examples: Number, String, Boolean, Undefined, Null, Symbol (ES6).
Non-Primitive Data Types (Reference Types):
Stored by reference: Non-primitive data types are stored by reference, meaning that the variable contains a reference (memory address) to the actual value stored elsewhere in memory.
Mutable: Non-primitive values can be modified because they are stored by reference. Changing the value through one reference affects all other references to that value.
Examples: Object, Array, Function, Date, RegExp.
Undefined
undefined is a primitive value that represents a variable or object property that has not been assigned a value.
It indicates that a variable has been declared but has not yet been initialized or assigned any value.
It is automatically assigned to variables that have been declared but not explicitly initialized.
Use undefined when a variable or object property has not been assigned any value, either because it has not been initialized or because it has been explicitly set to undefined.
null
null is a primitive value that represents the intentional absence of any object value.
It is often used to explicitly indicate that a variable or object does not have a value.
null is explicitly assigned by developers to signify that a variable or object property should not reference any object.
Use null when you want to explicitly denote the intentional absence of a value.