JavaScript Flashcards
To gain a better overall understanding of everything JavaScript
.includes
determines whether an array includes a certain value among its entries, returning true or false as appropriate.
- arr.includes(valueToFind[, fromIndex])
how do you prevent a submit button from refreshing the page when clicked?
in the handleSubmit function insert
e.preventDefault( );
what are two methods to convert a string to a number?
- add + directly before the element
2. type parse(int) directly before the element
a method that returns an array of a given object’s own enumerable property names, in the same order as we get with a normal loop.
Object.keys(obj name)
Return value is An array of strings that represent all the enumerable properties of the given object. The ordering is the same as a for loop.
will return an array from an object, but the array will contain more arrays that have both the key and value of the properties in an object.
Object.entries(obj name)
used to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object.
Object.assign(target, ...sources) target The target object. sources The source object(s). Return Value: The target object.
What do you call the object that a method belongs to?
The calling object
refers the calling object and can be used to access properties of the calling object.
The this keyword
What does the usage of an underscore before a property name mean?
that the original developer did not intend for that property to be directly changed.
allow us to create object instances quickly and repeatedly.
Factory functions
Name two ways to use object destructuring?
one way is the property value shorthand and another is destructured assignment.