Update formatting
This commit is contained in:
@ -8,7 +8,7 @@ lastUpdated: 2020-10-22T20:23:47+03:00
|
|||||||
Finds the last key that satisfies the provided testing function.
|
Finds the last key that satisfies the provided testing function.
|
||||||
Otherwise `undefined` is returned.
|
Otherwise `undefined` is returned.
|
||||||
|
|
||||||
- Use `Object.keys(obj)` to get all the properties of the object.
|
- Use `Object.keys()` to get all the properties of the object.
|
||||||
- Use `Array.prototype.reverse()` to reverse the order and `Array.prototype.find()` to test the provided function for each key-value pair.
|
- Use `Array.prototype.reverse()` to reverse the order and `Array.prototype.find()` to test the provided function for each key-value pair.
|
||||||
- The callback receives three arguments - the value, the key and the object.
|
- The callback receives three arguments - the value, the key and the object.
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ lastUpdated: 2020-10-19T18:51:03+03:00
|
|||||||
Flattens an object with the paths for keys.
|
Flattens an object with the paths for keys.
|
||||||
|
|
||||||
- Use recursion.
|
- Use recursion.
|
||||||
- Use `Object.keys(obj)` combined with `Array.prototype.reduce()` to convert every leaf node to a flattened path node.
|
- Use `Object.keys()` combined with `Array.prototype.reduce()` to convert every leaf node to a flattened path node.
|
||||||
- If the value of a key is an object, the function calls itself with the appropriate `prefix` to create the path using `Object.assign()`.
|
- If the value of a key is an object, the function calls itself with the appropriate `prefix` to create the path using `Object.assign()`.
|
||||||
- Otherwise, it adds the appropriate prefixed key-value pair to the accumulator object.
|
- Otherwise, it adds the appropriate prefixed key-value pair to the accumulator object.
|
||||||
- You should always omit the second argument, `prefix`, unless you want every key to have a prefix.
|
- You should always omit the second argument, `prefix`, unless you want every key to have a prefix.
|
||||||
|
|||||||
@ -7,7 +7,7 @@ lastUpdated: 2020-10-22T20:23:47+03:00
|
|||||||
|
|
||||||
Iterates over all own properties of an object, running a callback for each one.
|
Iterates over all own properties of an object, running a callback for each one.
|
||||||
|
|
||||||
- Use `Object.keys(obj)` to get all the properties of the object.
|
- Use `Object.keys()` to get all the properties of the object.
|
||||||
- Use `Array.prototype.forEach()` to run the provided function for each key-value pair.
|
- Use `Array.prototype.forEach()` to run the provided function for each key-value pair.
|
||||||
- The callback receives three arguments - the value, the key and the object.
|
- The callback receives three arguments - the value, the key and the object.
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ lastUpdated: 2020-10-19T22:49:51+03:00
|
|||||||
|
|
||||||
Iterates over all own properties of an object in reverse, running a callback for each one.
|
Iterates over all own properties of an object in reverse, running a callback for each one.
|
||||||
|
|
||||||
- Use `Object.keys(obj)` to get all the properties of the object, `Array.prototype.reverse()` to reverse their order.
|
- Use `Object.keys()` to get all the properties of the object, `Array.prototype.reverse()` to reverse their order.
|
||||||
- Use `Array.prototype.forEach()` to run the provided function for each key-value pair.
|
- Use `Array.prototype.forEach()` to run the provided function for each key-value pair.
|
||||||
- The callback receives three arguments - the value, the key and the object.
|
- The callback receives three arguments - the value, the key and the object.
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,8 @@ lastUpdated: 2020-10-20T11:21:07+03:00
|
|||||||
|
|
||||||
Gets an array of function property names from own (and optionally inherited) enumerable properties of an object.
|
Gets an array of function property names from own (and optionally inherited) enumerable properties of an object.
|
||||||
|
|
||||||
- Use `Object.keys(obj)` to iterate over the object's own properties.
|
- Use `Object.keys()` to iterate over the object's own properties.
|
||||||
- If `inherited` is `true`, use `Object.getPrototypeOf(obj)` to also get the object's inherited properties.
|
- If `inherited` is `true`, use `Object.getPrototypeOf()` to also get the object's inherited properties.
|
||||||
- Use `Array.prototype.filter()` to keep only those properties that are functions.
|
- Use `Array.prototype.filter()` to keep only those properties that are functions.
|
||||||
- Omit the second argument, `inherited`, to not include inherited properties by default.
|
- Omit the second argument, `inherited`, to not include inherited properties by default.
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ lastUpdated: 2020-10-22T20:24:04+03:00
|
|||||||
|
|
||||||
Generates a query string from the key-value pairs of the given object.
|
Generates a query string from the key-value pairs of the given object.
|
||||||
|
|
||||||
- Use `Array.prototype.reduce()` on `Object.entries(queryParameters)` to create the query string.
|
- Use `Array.prototype.reduce()` on `Object.entries()` to create the query string from `queryParameters`.
|
||||||
- Determine the `symbol` to be either `?` or `&` based on the length of `queryString`.
|
- Determine the `symbol` to be either `?` or `&` based on the length of `queryString`.
|
||||||
- Concatenate `val` to `queryString` only if it's a string.
|
- Concatenate `val` to `queryString` only if it's a string.
|
||||||
- Return the `queryString` or an empty string when the `queryParameters` are falsy.
|
- Return the `queryString` or an empty string when the `queryParameters` are falsy.
|
||||||
|
|||||||
@ -7,7 +7,7 @@ lastUpdated: 2020-10-22T20:24:04+03:00
|
|||||||
|
|
||||||
Creates an object composed of the properties the given function returns truthy for.
|
Creates an object composed of the properties the given function returns truthy for.
|
||||||
|
|
||||||
- Use `Object.keys(obj)` and `Array.prototype.filter()`to remove the keys for which `fn` returns a falsy value.
|
- Use `Object.keys()` and `Array.prototype.filter()`to remove the keys for which `fn` returns a falsy value.
|
||||||
- Use `Array.prototype.reduce()` to convert the filtered keys back to an object with the corresponding key-value pairs.
|
- Use `Array.prototype.reduce()` to convert the filtered keys back to an object with the corresponding key-value pairs.
|
||||||
- The callback function is invoked with two arguments: (value, key).
|
- The callback function is invoked with two arguments: (value, key).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user