Update formatting
This commit is contained in:
@ -7,7 +7,7 @@ lastUpdated: 2020-10-22T20:23:47+03:00
|
|||||||
|
|
||||||
Clones a regular expression.
|
Clones a regular expression.
|
||||||
|
|
||||||
- Use `new RegExp()`, `RegExp.prototype.source` and `RegExp.prototype.flags` to clone the given regular expression.
|
- Use the `RegExp` constructor, `RegExp.prototype.source` and `RegExp.prototype.flags` to clone the given regular expression.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
|
const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
|
||||||
|
|||||||
@ -8,7 +8,7 @@ lastUpdated: 2020-11-03T22:11:18+02:00
|
|||||||
Generates an object from the given query string or URL.
|
Generates an object from the given query string or URL.
|
||||||
|
|
||||||
- Use `String.prototype.split()` to get the params from the given `url`.
|
- Use `String.prototype.split()` to get the params from the given `url`.
|
||||||
- Use `new URLSearchParams()` to create an appropriate object and convert it to an array of key-value pairs using the spread operator (`...`).
|
- Use the `URLSearchParams` constructor to create an appropriate object and convert it to an array of key-value pairs using the spread operator (`...`).
|
||||||
- Use `Array.prototype.reduce()` to convert the array of key-value pairs into an object.
|
- Use `Array.prototype.reduce()` to convert the array of key-value pairs into an object.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@ -7,7 +7,7 @@ lastUpdated: 2020-10-22T20:24:30+03:00
|
|||||||
|
|
||||||
Serializes a JSON object containing circular references into a JSON format.
|
Serializes a JSON object containing circular references into a JSON format.
|
||||||
|
|
||||||
- Create a `new WeakSet()` to store and check seen values, using `WeakSet.prototype.add()` and `WeakSet.prototype.has()`.
|
- Create a `WeakSet` to store and check seen values, using `WeakSet.prototype.add()` and `WeakSet.prototype.has()`.
|
||||||
- Use `JSON.stringify()` with a custom replacer function that omits values already in `seen`, adding new values as necessary.
|
- Use `JSON.stringify()` with a custom replacer function that omits values already in `seen`, adding new values as necessary.
|
||||||
- ⚠️ **NOTICE:** This function finds and removes circular references, which causes circular data loss in the serialized JSON.
|
- ⚠️ **NOTICE:** This function finds and removes circular references, which causes circular data loss in the serialized JSON.
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ lastUpdated: 2020-10-22T20:24:44+03:00
|
|||||||
|
|
||||||
Triggers a specific event on a given element, optionally passing custom data.
|
Triggers a specific event on a given element, optionally passing custom data.
|
||||||
|
|
||||||
- Use `new CustomEvent()` to create an event from the specified `eventType` and details.
|
- Use the `CustomEvent` constructor to create an event from the specified `eventType` and details.
|
||||||
- Use `EventTarget.dispatchEvent()` to trigger the newly created event on the given element.
|
- Use `EventTarget.dispatchEvent()` to trigger the newly created event on the given element.
|
||||||
- Omit the third argument, `detail`, if you do not want to pass custom data to the triggered event.
|
- Omit the third argument, `detail`, if you do not want to pass custom data to the triggered event.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user