chunk_id
stringlengths
36
36
source
stringclasses
35 values
source_url
stringlengths
0
290
upstream_license
stringclasses
1 value
document_id
stringlengths
36
36
chunk_index
int64
0
324k
retrieved_at
stringclasses
2 values
chunker_version
stringclasses
4 values
content_hash
stringlengths
15
64
content
stringlengths
50
44.7k
namespace
stringclasses
9 values
source_name
stringclasses
35 values
raw_text
stringlengths
50
44.7k
cleaned_text
stringlengths
50
44.7k
tags
stringclasses
49 values
collection_name
stringclasses
11 values
3e4c0c4b-e710-42b7-9206-65b0838829ee
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-map-to-object.md
unknown
743c9104-4891-4d4b-a8bd-47815d70c5f3
2
SemanticChunker@1.0.0
8ccee1d58437df8b545bb6c1740ec453c3d4ebe05a28b339c8137a01fc8ac326
[Convert a Map to an object > Convert an object to a Map] ## Convert an object to a Map Similarly, using `Object.entries()`, we can convert an object to an **array of key-value pairs**. Then, we can use the `Map()` constructor to **convert the array to a Map**. ```js const objectToMap = obj => new Map(Object.entries...
unknown
unknown
[Convert a Map to an object > Convert an object to a Map] ## Convert an object to a Map Similarly, using `Object.entries()`, we can convert an object to an **array of key-value pairs**. Then, we can use the `Map()` constructor to **convert the array to a Map**. ```js const objectToMap = obj => new Map(Object.entries...
[Convert a Map to an object > Convert an object to a Map] ## Convert an object to a Map Similarly, using `Object.entries()`, we can convert an object to an **array of key-value pairs**. Then, we can use the `Map()` constructor to **convert the array to a Map**. ```js const objectToMap = obj => new Map(Object.entries...
code_snippets
7c180a86-b27a-4762-ac6a-6b50afe5a186
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-map-to-object.md
unknown
743c9104-4891-4d4b-a8bd-47815d70c5f3
1
SemanticChunker@1.0.0
b1a7f85495c7f17a301e5ab8a2442f68d2c3388b0182f6990e3c5d506a5ec60f
[Convert a Map to an object] ## Convert a Map to an object Using `Map.prototype.entries()`, we can convert a `Map` to an **array of key-value pairs**. Then, we can use `Object.fromEntries()` to convert the **array to an object**. ```js const mapToObject = map => Object.fromEntries(map.entries()); mapToObject(new Ma...
unknown
unknown
[Convert a Map to an object] ## Convert a Map to an object Using `Map.prototype.entries()`, we can convert a `Map` to an **array of key-value pairs**. Then, we can use `Object.fromEntries()` to convert the **array to an object**. ```js const mapToObject = map => Object.fromEntries(map.entries()); mapToObject(new Ma...
[Convert a Map to an object] ## Convert a Map to an object Using `Map.prototype.entries()`, we can convert a `Map` to an **array of key-value pairs**. Then, we can use `Object.fromEntries()` to convert the **array to an object**. ```js const mapToObject = map => Object.fromEntries(map.entries()); mapToObject(new Ma...
code_snippets
c548fd73-b2b5-4ca3-8d54-fb89382f918d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-map-to-object.md
unknown
743c9104-4891-4d4b-a8bd-47815d70c5f3
0
SemanticChunker@1.0.0
2a7d9e19e061f9482ef21a5af75bd7b93ee0707e355683bde88ef69c1b4cb76f
--- title: How can I convert a Map to a JavaScript object and vice versa? shortTitle: Map to object language: javascript tags: [object] cover: yellow-shoes excerpt: Learn how to convert between `Map`s and objects in JavaScript. listed: true dateModified: 2024-02-11 --- Oftentimes, when working with `Map` objects, we n...
unknown
unknown
--- title: How can I convert a Map to a JavaScript object and vice versa? shortTitle: Map to object language: javascript tags: [object] cover: yellow-shoes excerpt: Learn how to convert between `Map`s and objects in JavaScript. listed: true dateModified: 2024-02-11 --- Oftentimes, when working with `Map` objects, we n...
--- title: How can I convert a Map to a JavaScript object and vice versa? shortTitle: Map to object language: javascript tags: [object] cover: yellow-shoes excerpt: Learn how to convert between `Map`s and objects in JavaScript. listed: true dateModified: 2024-02-11 --- Oftentimes, when working with `Map` objects, we n...
code_snippets
9ae3d447-c46f-41e1-8f4c-be3fd6c62566
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-degrees-radians.md
unknown
b48ee49c-5b2b-473a-8335-ade5ceea7d99
2
SemanticChunker@1.0.0
1ba4891340a3f9359e1b5b6e6215e95079ea374d0e481e2a76da08cd1f5ea07d
[Degrees to radians > Radians to degrees] ## Radians to degrees Conversely, the conversion formula from radians to degrees is `degrees = radians * 180.0 / Math.PI`. <latex-expression> ```math d = \frac{r \times 180}{\pi} ``` </latex-expression> ```js const radsToDegrees = rad => (rad * 180.0) / Math.PI; radsToDe...
unknown
unknown
[Degrees to radians > Radians to degrees] ## Radians to degrees Conversely, the conversion formula from radians to degrees is `degrees = radians * 180.0 / Math.PI`. <latex-expression> ```math d = \frac{r \times 180}{\pi} ``` </latex-expression> ```js const radsToDegrees = rad => (rad * 180.0) / Math.PI; radsToDe...
[Degrees to radians > Radians to degrees] ## Radians to degrees Conversely, the conversion formula from radians to degrees is `degrees = radians * 180.0 / Math.PI`. <latex-expression> ```math d = \frac{r \times 180}{\pi} ``` </latex-expression> ```js const radsToDegrees = rad => (rad * 180.0) / Math.PI; radsToDe...
code_snippets
b1dac425-f76f-44d5-9f9b-3c308778f886
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-degrees-radians.md
unknown
b48ee49c-5b2b-473a-8335-ade5ceea7d99
1
SemanticChunker@1.0.0
e8e6913dee2c980f7ef578751eb64ce123de35c8d9e5333e917a6324f8aba48f
[Degrees to radians] ## Degrees to radians JavaScript's `Math.PI` constant can be used to convert an angle from degrees to radians. The conversion formula is `radians = degrees * Math.PI / 180.0`. <latex-expression> ```math r = \frac{d \times \pi}{180} ``` </latex-expression> ```js const degreesToRads = deg => (d...
unknown
unknown
[Degrees to radians] ## Degrees to radians JavaScript's `Math.PI` constant can be used to convert an angle from degrees to radians. The conversion formula is `radians = degrees * Math.PI / 180.0`. <latex-expression> ```math r = \frac{d \times \pi}{180} ``` </latex-expression> ```js const degreesToRads = deg => (d...
[Degrees to radians] ## Degrees to radians JavaScript's `Math.PI` constant can be used to convert an angle from degrees to radians. The conversion formula is `radians = degrees * Math.PI / 180.0`. <latex-expression> ```math r = \frac{d \times \pi}{180} ``` </latex-expression> ```js const degreesToRads = deg => (d...
code_snippets
fb03b909-0c84-43b7-bda0-ddbfea799d79
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-degrees-radians.md
unknown
b48ee49c-5b2b-473a-8335-ade5ceea7d99
0
SemanticChunker@1.0.0
a55e1cca446a8a21e25c23ffde27274bd9ec5da444fc7e48e8acecb11134544e
--- title: Convert between degrees and radians in JavaScript shortTitle: Convert between degrees and radians language: javascript tags: [math] cover: blue-flower excerpt: Easily apply the degree to radian and radian to degree formulas. listed: true dateModified: 2023-09-15 ---
unknown
unknown
--- title: Convert between degrees and radians in JavaScript shortTitle: Convert between degrees and radians language: javascript tags: [math] cover: blue-flower excerpt: Easily apply the degree to radian and radian to degree formulas. listed: true dateModified: 2023-09-15 ---
--- title: Convert between degrees and radians in JavaScript shortTitle: Convert between degrees and radians language: javascript tags: [math] cover: blue-flower excerpt: Easily apply the degree to radian and radian to degree formulas. listed: true dateModified: 2023-09-15 ---
code_snippets
147109fe-edbf-4ee5-91fc-920cf562fbf3
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/cookies-local-storage-session.md
unknown
5dda77be-a989-4473-b2fb-1b3012c95cf7
2
SemanticChunker@1.0.0
46b1404de36badaf953b3f1119ee2b65f8a4bde10bf1e3fbefcc8ca584b92f12
[Cookies > Local storage] ## Local storage Local storage stores a larger amount of data on the client's computer in a key-value pair format and has no expiration date. Data is never transferred to the server and is accessible via JavaScript and HTML5. - Capacity: 10MB - Accessible from: Any window - Expiration: Neve...
unknown
unknown
[Cookies > Local storage] ## Local storage Local storage stores a larger amount of data on the client's computer in a key-value pair format and has no expiration date. Data is never transferred to the server and is accessible via JavaScript and HTML5. - Capacity: 10MB - Accessible from: Any window - Expiration: Neve...
[Cookies > Local storage] ## Local storage Local storage stores a larger amount of data on the client's computer in a key-value pair format and has no expiration date. Data is never transferred to the server and is accessible via JavaScript and HTML5. - Capacity: 10MB - Accessible from: Any window - Expiration: Neve...
code_snippets
965e45ea-e2ed-4308-b798-1537e993c707
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/cookies-local-storage-session.md
unknown
5dda77be-a989-4473-b2fb-1b3012c95cf7
1
SemanticChunker@1.0.0
2fe6544a49c7852bd3a729176afaae4c3dd969d1870d4db7512531e1839022a3
[Cookies] ## Cookies Cookies store small amounts of data that has to be sent back to the server with subsequent requests and their expiration can be set from either server or client. They are primarily used for server-side reading. - Capacity: 4KB - Accessible from: Any window - Expiration: Manually set - Storage lo...
unknown
unknown
[Cookies] ## Cookies Cookies store small amounts of data that has to be sent back to the server with subsequent requests and their expiration can be set from either server or client. They are primarily used for server-side reading. - Capacity: 4KB - Accessible from: Any window - Expiration: Manually set - Storage lo...
[Cookies] ## Cookies Cookies store small amounts of data that has to be sent back to the server with subsequent requests and their expiration can be set from either server or client. They are primarily used for server-side reading. - Capacity: 4KB - Accessible from: Any window - Expiration: Manually set - Storage lo...
code_snippets
a6491478-ec8e-4e16-b73f-61ef2e26de3d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/cookies-local-storage-session.md
unknown
5dda77be-a989-4473-b2fb-1b3012c95cf7
0
SemanticChunker@1.0.0
eae6b71384e92793999b3e3c757544d1d6d1ab2b014cf1a5cdb803451df5fa2b
--- title: What is the difference between cookies, local storage, and session storage? shortTitle: Cookies, local storage, and session storage language: javascript tags: [browser,webdev] cover: three-vases excerpt: Learn the difference between cookies, local storage and session storage and start using the correct optio...
unknown
unknown
--- title: What is the difference between cookies, local storage, and session storage? shortTitle: Cookies, local storage, and session storage language: javascript tags: [browser,webdev] cover: three-vases excerpt: Learn the difference between cookies, local storage and session storage and start using the correct optio...
--- title: What is the difference between cookies, local storage, and session storage? shortTitle: Cookies, local storage, and session storage language: javascript tags: [browser,webdev] cover: three-vases excerpt: Learn the difference between cookies, local storage and session storage and start using the correct optio...
code_snippets
bf98ee02-24ae-49f4-a467-e5db53c2742e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/cookies-local-storage-session.md
unknown
5dda77be-a989-4473-b2fb-1b3012c95cf7
3
SemanticChunker@1.0.0
b173e4f7079416de5bbd1e8901150c65c9a6a768fde10e96cfe9f0a2c71e1ae5
[Cookies > Session storage] ## Session storage Session storage stores a larger amount of data on the client's computer only for the current session, expiring the data on tab close. Data is never transferred to the server and is accessible client-side from the same tab. - Capacity: 5MB - Accessible from: Same tab - E...
unknown
unknown
[Cookies > Session storage] ## Session storage Session storage stores a larger amount of data on the client's computer only for the current session, expiring the data on tab close. Data is never transferred to the server and is accessible client-side from the same tab. - Capacity: 5MB - Accessible from: Same tab - E...
[Cookies > Session storage] ## Session storage Session storage stores a larger amount of data on the client's computer only for the current session, expiring the data on tab close. Data is never transferred to the server and is accessible client-side from the same tab. - Capacity: 5MB - Accessible from: Same tab - E...
code_snippets
15d24dbb-249c-4d1c-9a8b-303e9ffc4968
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-celsius-fahrenheit.md
unknown
13e54d22-b5b7-4654-8bf5-cb7b83791a6f
1
SemanticChunker@1.0.0
6f4dc3015e348b81252d8c26dfb39bcf0ef1c846983e86254534860f99b77ff1
[Celsius to Fahrenheit] ## Celsius to Fahrenheit In order to convert from Celsius to Fahrenheit, you can use the conversion formula `F = 1.8 * C + 32`. <latex-expression> ```math F = 1.8 \times C + 32 ``` </latex-expression> ```js const celsiusToFahrenheit = degrees => 1.8 * degrees + 32; celsiusToFahrenheit(33)...
unknown
unknown
[Celsius to Fahrenheit] ## Celsius to Fahrenheit In order to convert from Celsius to Fahrenheit, you can use the conversion formula `F = 1.8 * C + 32`. <latex-expression> ```math F = 1.8 \times C + 32 ``` </latex-expression> ```js const celsiusToFahrenheit = degrees => 1.8 * degrees + 32; celsiusToFahrenheit(33)...
[Celsius to Fahrenheit] ## Celsius to Fahrenheit In order to convert from Celsius to Fahrenheit, you can use the conversion formula `F = 1.8 * C + 32`. <latex-expression> ```math F = 1.8 \times C + 32 ``` </latex-expression> ```js const celsiusToFahrenheit = degrees => 1.8 * degrees + 32; celsiusToFahrenheit(33)...
code_snippets
513bcca9-e102-445e-9d4c-f78300bd99a9
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-celsius-fahrenheit.md
unknown
13e54d22-b5b7-4654-8bf5-cb7b83791a6f
0
SemanticChunker@1.0.0
6888bce812a8e5c8f02bd6f715ef02aa54fa36cd3a624517c4af063efd3b64b1
--- title: Convert between Celsius and Fahrenheit in JavaScript shortTitle: Convert between Celsius and Fahrenheit language: javascript tags: [math] cover: golden-gate-bridge excerpt: Easily apply the Celsius to Fahrenheit and Fahrenheit to Celsius formulas. listed: false dateModified: 2023-09-14 ---
unknown
unknown
--- title: Convert between Celsius and Fahrenheit in JavaScript shortTitle: Convert between Celsius and Fahrenheit language: javascript tags: [math] cover: golden-gate-bridge excerpt: Easily apply the Celsius to Fahrenheit and Fahrenheit to Celsius formulas. listed: false dateModified: 2023-09-14 ---
--- title: Convert between Celsius and Fahrenheit in JavaScript shortTitle: Convert between Celsius and Fahrenheit language: javascript tags: [math] cover: golden-gate-bridge excerpt: Easily apply the Celsius to Fahrenheit and Fahrenheit to Celsius formulas. listed: false dateModified: 2023-09-14 ---
code_snippets
912c3433-2509-4056-bd31-e2aff9d4e842
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-celsius-fahrenheit.md
unknown
13e54d22-b5b7-4654-8bf5-cb7b83791a6f
2
SemanticChunker@1.0.0
abd490d583c4f2c80e77dd9a2fdd719f1d7feedb11584574fe516b7db7e59bee
[Celsius to Fahrenheit > Fahrenheit to Celsius] ## Fahrenheit to Celsius Conversely, the conversion formula from Fahrenheit to Celsius is `C = (F - 32) * 5 / 9`. <latex-expression> ```math C = (F - 32) \times \frac{5}{9} ``` </latex-expression> ```js const fahrenheitToCelsius = degrees => (degrees - 32) * 5 / 9; ...
unknown
unknown
[Celsius to Fahrenheit > Fahrenheit to Celsius] ## Fahrenheit to Celsius Conversely, the conversion formula from Fahrenheit to Celsius is `C = (F - 32) * 5 / 9`. <latex-expression> ```math C = (F - 32) \times \frac{5}{9} ``` </latex-expression> ```js const fahrenheitToCelsius = degrees => (degrees - 32) * 5 / 9; ...
[Celsius to Fahrenheit > Fahrenheit to Celsius] ## Fahrenheit to Celsius Conversely, the conversion formula from Fahrenheit to Celsius is `C = (F - 32) * 5 / 9`. <latex-expression> ```math C = (F - 32) \times \frac{5}{9} ``` </latex-expression> ```js const fahrenheitToCelsius = degrees => (degrees - 32) * 5 / 9; ...
code_snippets
9c65829d-b5a8-4519-b36b-ecad9d9bff44
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-to-absolute-path.md
unknown
f1d09837-7926-476a-a567-cde01dd5223f
0
SemanticChunker@1.0.0
f111399d32605fefd0e9caed761ade7e303de8a5ec804b9bbf82af0fafe03fb7
--- title: Convert a tilde path to an absolute path in Node.js shortTitle: Convert to absolute path language: javascript tags: [node,string,regexp] cover: lighthouse excerpt: Ever wanted to convert a tilde path to an absolute path? Here's how you can do it in JavaScript. listed: true dateModified: 2024-03-19 --- Have ...
unknown
unknown
--- title: Convert a tilde path to an absolute path in Node.js shortTitle: Convert to absolute path language: javascript tags: [node,string,regexp] cover: lighthouse excerpt: Ever wanted to convert a tilde path to an absolute path? Here's how you can do it in JavaScript. listed: true dateModified: 2024-03-19 --- Have ...
--- title: Convert a tilde path to an absolute path in Node.js shortTitle: Convert to absolute path language: javascript tags: [node,string,regexp] cover: lighthouse excerpt: Ever wanted to convert a tilde path to an absolute path? Here's how you can do it in JavaScript. listed: true dateModified: 2024-03-19 --- Have ...
code_snippets
148b39c7-8a33-45b4-b1a2-6f95fdcdfbc7
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-array.md
unknown
e70f3034-9438-4175-93be-19acf10fd5ee
6
SemanticChunker@1.0.0
eb59a9903aae1ec983a65e40206d5b40f3a1107f190d7fc9d6f08a77ff75d2f0
[The spread operator > Object.assign()] ## Object.assign() Finally, `Object.assign()` can be used in the exact same way as it's used to create a clone of an object, but for an array instead. ```js let x = [1, 2, 3, 4]; let y = Object.assign([], x); ```
unknown
unknown
[The spread operator > Object.assign()] ## Object.assign() Finally, `Object.assign()` can be used in the exact same way as it's used to create a clone of an object, but for an array instead. ```js let x = [1, 2, 3, 4]; let y = Object.assign([], x); ```
[The spread operator > Object.assign()] ## Object.assign() Finally, `Object.assign()` can be used in the exact same way as it's used to create a clone of an object, but for an array instead. ```js let x = [1, 2, 3, 4]; let y = Object.assign([], x); ```
code_snippets
2b712df3-73a8-496a-a0dd-e63fd5d6140f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-array.md
unknown
e70f3034-9438-4175-93be-19acf10fd5ee
2
SemanticChunker@1.0.0
f30df8ac19f2ea83d824e827af349afd8d3808ae0bea7cfe6489dde55c09fd29
[The spread operator > Array.from()] ## Array.from() `Array.from()` has a very powerful API that can be used for many different things, including creating a copy of an array. ```js let x = [1, 2, 3, 4]; let y = Array.from(x); ```
unknown
unknown
[The spread operator > Array.from()] ## Array.from() `Array.from()` has a very powerful API that can be used for many different things, including creating a copy of an array. ```js let x = [1, 2, 3, 4]; let y = Array.from(x); ```
[The spread operator > Array.from()] ## Array.from() `Array.from()` has a very powerful API that can be used for many different things, including creating a copy of an array. ```js let x = [1, 2, 3, 4]; let y = Array.from(x); ```
code_snippets
3c9db5a9-8fca-4987-bdc1-c3471567a347
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-array.md
unknown
e70f3034-9438-4175-93be-19acf10fd5ee
4
SemanticChunker@1.0.0
ed5edf4031ae7e9d090e23698b9808be2f7cbc97ef28d5d4c87e2d24dd7992de
[The spread operator > Array.prototype.map()] ## Array.prototype.map() Looking into one of the more unorthodox options, `Array.prototype.map()` can be used to map each element of an array to itself to create a new array. ```js let x = [1, 2, 3, 4]; let y = x.map(i => i); ```
unknown
unknown
[The spread operator > Array.prototype.map()] ## Array.prototype.map() Looking into one of the more unorthodox options, `Array.prototype.map()` can be used to map each element of an array to itself to create a new array. ```js let x = [1, 2, 3, 4]; let y = x.map(i => i); ```
[The spread operator > Array.prototype.map()] ## Array.prototype.map() Looking into one of the more unorthodox options, `Array.prototype.map()` can be used to map each element of an array to itself to create a new array. ```js let x = [1, 2, 3, 4]; let y = x.map(i => i); ```
code_snippets
412211fe-c4d6-4d76-9d65-63dfd20e2e0c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-array.md
unknown
e70f3034-9438-4175-93be-19acf10fd5ee
5
SemanticChunker@1.0.0
6f8fbd03ccecc07056012e661d566a38f618660505e440d25f3f9a7fed9608ce
[The spread operator > Array.prototype.filter()] ## Array.prototype.filter() Similarly, `Array.prototype.filter()` can be used to return `true` for each and every element, resulting in a new array with all of the original array's elements. ```js let x = [1, 2, 3, 4]; let y = x.filter(() => true); ```
unknown
unknown
[The spread operator > Array.prototype.filter()] ## Array.prototype.filter() Similarly, `Array.prototype.filter()` can be used to return `true` for each and every element, resulting in a new array with all of the original array's elements. ```js let x = [1, 2, 3, 4]; let y = x.filter(() => true); ```
[The spread operator > Array.prototype.filter()] ## Array.prototype.filter() Similarly, `Array.prototype.filter()` can be used to return `true` for each and every element, resulting in a new array with all of the original array's elements. ```js let x = [1, 2, 3, 4]; let y = x.filter(() => true); ```
code_snippets
561bcfa3-96ce-485e-81a8-cf03a18a02c0
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-array.md
unknown
e70f3034-9438-4175-93be-19acf10fd5ee
3
SemanticChunker@1.0.0
b1309762ceed971b5ad4d01679321cb526a1d7c36b032d9e704f18db8f6d2794
[The spread operator > Array.prototype.slice()] ## Array.prototype.slice() Similarly to the spread operator, `Array.prototype.slice()` can be used to create a shallow copy of an array. ```js let x = [1, 2, 3, 4]; let y = x.slice(); ```
unknown
unknown
[The spread operator > Array.prototype.slice()] ## Array.prototype.slice() Similarly to the spread operator, `Array.prototype.slice()` can be used to create a shallow copy of an array. ```js let x = [1, 2, 3, 4]; let y = x.slice(); ```
[The spread operator > Array.prototype.slice()] ## Array.prototype.slice() Similarly to the spread operator, `Array.prototype.slice()` can be used to create a shallow copy of an array. ```js let x = [1, 2, 3, 4]; let y = x.slice(); ```
code_snippets
7df3735d-3b98-4e4d-a575-d6d50f68d2a7
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-array.md
unknown
e70f3034-9438-4175-93be-19acf10fd5ee
0
SemanticChunker@1.0.0
1a251b069efc46c2dbba5ea8e4cf2e3794321aadcbe7a913f164b44be607cba6
--- title: How can I clone an array in JavaScript? shortTitle: Clone an array language: javascript tags: [array] cover: colorful-plastic excerpt: Pick up a few new tricks which you can use to clone arrays in JavaScript. listed: true dateModified: 2021-06-12 --- JavaScript provides quite a few ways to clone an array, m...
unknown
unknown
--- title: How can I clone an array in JavaScript? shortTitle: Clone an array language: javascript tags: [array] cover: colorful-plastic excerpt: Pick up a few new tricks which you can use to clone arrays in JavaScript. listed: true dateModified: 2021-06-12 --- JavaScript provides quite a few ways to clone an array, m...
--- title: How can I clone an array in JavaScript? shortTitle: Clone an array language: javascript tags: [array] cover: colorful-plastic excerpt: Pick up a few new tricks which you can use to clone arrays in JavaScript. listed: true dateModified: 2021-06-12 --- JavaScript provides quite a few ways to clone an array, m...
code_snippets
b009ecdf-3e5d-4b85-87bd-54fad564f860
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-array.md
unknown
e70f3034-9438-4175-93be-19acf10fd5ee
7
SemanticChunker@1.0.0
be95957ecb0ac6a313c11d92f70f098b29d4dd6052202f52d8aa5b5de2cd3298
[The spread operator > structuredClone()] ## structuredClone() <baseline-support featureId="structured-clone"> </baseline-support> If you're looking to clone an array that contains objects, functions or class instances, you can use the `structuredClone()` global function, which can be used to deep clone objects. ``...
unknown
unknown
[The spread operator > structuredClone()] ## structuredClone() <baseline-support featureId="structured-clone"> </baseline-support> If you're looking to clone an array that contains objects, functions or class instances, you can use the `structuredClone()` global function, which can be used to deep clone objects. ``...
[The spread operator > structuredClone()] ## structuredClone() <baseline-support featureId="structured-clone"> </baseline-support> If you're looking to clone an array that contains objects, functions or class instances, you can use the `structuredClone()` global function, which can be used to deep clone objects. ``...
code_snippets
effa991a-0231-4ede-b3c0-bdce07615bfb
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-array.md
unknown
e70f3034-9438-4175-93be-19acf10fd5ee
1
SemanticChunker@1.0.0
0b804cd3ff75b3750396c4e1d8d673d7e42fdf3e23b349558a2a4c706bf2a945
[The spread operator] ## The spread operator ES6 introduced the spread operator (`...`), which provides probably the easiest and most common way to create a shallow clone of an array. ```js let x = [1, 2, 3, 4]; let y = [...x]; ```
unknown
unknown
[The spread operator] ## The spread operator ES6 introduced the spread operator (`...`), which provides probably the easiest and most common way to create a shallow clone of an array. ```js let x = [1, 2, 3, 4]; let y = [...x]; ```
[The spread operator] ## The spread operator ES6 introduced the spread operator (`...`), which provides probably the easiest and most common way to create a shallow clone of an array. ```js let x = [1, 2, 3, 4]; let y = [...x]; ```
code_snippets
457160da-2196-4339-8df9-291036fb26ad
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-miles-km.md
unknown
f6672a88-de00-4be5-b782-5026a28234cd
0
SemanticChunker@1.0.0
727b5c92efbae6f38ff9342c6a01cf37065ecc5fc77904b59f71b6d7288b2a39
--- title: Convert between miles and kilometers in JavaScript shortTitle: Convert between miles and kilometers language: javascript tags: [math] cover: rocky-beach-2 excerpt: Easily apply the mile to kilometer and kilometer to mile formulas. listed: false dateModified: 2023-09-13 ---
unknown
unknown
--- title: Convert between miles and kilometers in JavaScript shortTitle: Convert between miles and kilometers language: javascript tags: [math] cover: rocky-beach-2 excerpt: Easily apply the mile to kilometer and kilometer to mile formulas. listed: false dateModified: 2023-09-13 ---
--- title: Convert between miles and kilometers in JavaScript shortTitle: Convert between miles and kilometers language: javascript tags: [math] cover: rocky-beach-2 excerpt: Easily apply the mile to kilometer and kilometer to mile formulas. listed: false dateModified: 2023-09-13 ---
code_snippets
cd64ef70-5f01-4741-a65f-cfa5dc634db3
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-miles-km.md
unknown
f6672a88-de00-4be5-b782-5026a28234cd
2
SemanticChunker@1.0.0
6bdf84a6f03479e2ac85761192133e19ecab91bf238c0888a6bb51d21bf6e484
[Miles to kilometers > Kilometers to miles] ## Kilometers to miles Conversely, the conversion formula from kilometers to miles is `mi = km * 0.621371`. <latex-expression> ```math mi = km \times 0.621371 ``` </latex-expression> ```js const kmToMiles = km => km * 0.621371; kmToMiles(8.1) // 5.0331051 ```
unknown
unknown
[Miles to kilometers > Kilometers to miles] ## Kilometers to miles Conversely, the conversion formula from kilometers to miles is `mi = km * 0.621371`. <latex-expression> ```math mi = km \times 0.621371 ``` </latex-expression> ```js const kmToMiles = km => km * 0.621371; kmToMiles(8.1) // 5.0331051 ```
[Miles to kilometers > Kilometers to miles] ## Kilometers to miles Conversely, the conversion formula from kilometers to miles is `mi = km * 0.621371`. <latex-expression> ```math mi = km \times 0.621371 ``` </latex-expression> ```js const kmToMiles = km => km * 0.621371; kmToMiles(8.1) // 5.0331051 ```
code_snippets
cffc027b-aa06-4618-a29f-ecb80a350d63
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-miles-km.md
unknown
f6672a88-de00-4be5-b782-5026a28234cd
1
SemanticChunker@1.0.0
cd6ba01fa909987a5a73d3d5965797e04f9cd17c195ea4daac42fcb6ddd000f0
[Miles to kilometers] ## Miles to kilometers In order to convert from miles to kilometers, you can use the conversion formula `km = mi * 1.609344`. <latex-expression> ```math km = mi \times 1.609344 ``` </latex-expression> ```js const milesToKm = miles => miles * 1.609344; milesToKm(5); // ~8.04672 ```
unknown
unknown
[Miles to kilometers] ## Miles to kilometers In order to convert from miles to kilometers, you can use the conversion formula `km = mi * 1.609344`. <latex-expression> ```math km = mi \times 1.609344 ``` </latex-expression> ```js const milesToKm = miles => miles * 1.609344; milesToKm(5); // ~8.04672 ```
[Miles to kilometers] ## Miles to kilometers In order to convert from miles to kilometers, you can use the conversion formula `km = mi * 1.609344`. <latex-expression> ```math km = mi \times 1.609344 ``` </latex-expression> ```js const milesToKm = miles => miles * 1.609344; milesToKm(5); // ~8.04672 ```
code_snippets
44b7d4fe-ebec-4047-b1c9-67f6688560dc
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/construct-url.md
unknown
b2d13afa-2b40-431c-bcd0-a2b448226f1b
0
SemanticChunker@1.0.0
51033fa8f6e2d972273ac5f1a0b2f6cb8a934d11af2eaa762082bb41acaa1e82
--- title: How to construct a URL in JavaScript shortTitle: Construct a URL in JavaScript language: javascript tags: [string,browser] cover: alfama excerpt: A short guide on how to correctly construct a URL in JavaScript. listed: true dateModified: 2023-02-26 --- Oftentimes, we need to **create a URL in JavaScript**, ...
unknown
unknown
--- title: How to construct a URL in JavaScript shortTitle: Construct a URL in JavaScript language: javascript tags: [string,browser] cover: alfama excerpt: A short guide on how to correctly construct a URL in JavaScript. listed: true dateModified: 2023-02-26 --- Oftentimes, we need to **create a URL in JavaScript**, ...
--- title: How to construct a URL in JavaScript shortTitle: Construct a URL in JavaScript language: javascript tags: [string,browser] cover: alfama excerpt: A short guide on how to correctly construct a URL in JavaScript. listed: true dateModified: 2023-02-26 --- Oftentimes, we need to **create a URL in JavaScript**, ...
code_snippets
6dc049e7-9b6e-4948-bc81-43e90bb74452
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/construct-url.md
unknown
b2d13afa-2b40-431c-bcd0-a2b448226f1b
1
SemanticChunker@1.0.0
d67b8b452a8ffbedf5fd0b8d3f9f43ba9b3b4d8b0c7aa4b16850f5716f90c208
Surely, this dealt with encoding, but the multiline string has sneaked a newline character (`\n`) into the URL. This is because template literals preserve whitespace, leading to such issues. Breaking the string into multiple lines and concatenating them can help, but the code is starting to get ugly. Obviously, there ...
unknown
unknown
Surely, this dealt with encoding, but the multiline string has sneaked a newline character (`\n`) into the URL. This is because template literals preserve whitespace, leading to such issues. Breaking the string into multiple lines and concatenating them can help, but the code is starting to get ugly. Obviously, there ...
Surely, this dealt with encoding, but the multiline string has sneaked a newline character (`\n`) into the URL. This is because template literals preserve whitespace, leading to such issues. Breaking the string into multiple lines and concatenating them can help, but the code is starting to get ugly. Obviously, there ...
code_snippets
8f376e15-3234-4d18-bdf3-565938369bd1
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-sign-to-number.md
unknown
20476764-853a-4d52-945b-2621351818c7
0
SemanticChunker@1.0.0
74cfd18d83840c4b13190352d645f797679b54da4fc652a8101d71be132b48d6
--- title: Copy sign from one number to another in JavaScript shortTitle: Copy sign to number language: javascript tags: [math] cover: cloudy-mountaintop excerpt: Copy the sign of one number to another without changing its absolute value. listed: true dateModified: 2024-05-28 --- If you've ever worked extensively with...
unknown
unknown
--- title: Copy sign from one number to another in JavaScript shortTitle: Copy sign to number language: javascript tags: [math] cover: cloudy-mountaintop excerpt: Copy the sign of one number to another without changing its absolute value. listed: true dateModified: 2024-05-28 --- If you've ever worked extensively with...
--- title: Copy sign from one number to another in JavaScript shortTitle: Copy sign to number language: javascript tags: [math] cover: cloudy-mountaintop excerpt: Copy the sign of one number to another without changing its absolute value. listed: true dateModified: 2024-05-28 --- If you've ever worked extensively with...
code_snippets
1dd6567a-2926-41e6-8b35-06e6c3bbb846
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
6
SemanticChunker@1.0.0
2cbc7a7ce24ec66f42a375a92fafb3011177e0b1c69e5db18b9a4f513b125262
[Object to CSV > Object serialization] #### Object serialization Now that we have the headers, we can use them to serialize the objects into CSV. In order to allow for more flexibility, we'll pass the headers as an argument to the function. This way, we can **omit headers or include only specific ones**. The default ...
unknown
unknown
[Object to CSV > Object serialization] #### Object serialization Now that we have the headers, we can use them to serialize the objects into CSV. In order to allow for more flexibility, we'll pass the headers as an argument to the function. This way, we can **omit headers or include only specific ones**. The default ...
[Object to CSV > Object serialization] #### Object serialization Now that we have the headers, we can use them to serialize the objects into CSV. In order to allow for more flexibility, we'll pass the headers as an argument to the function. This way, we can **omit headers or include only specific ones**. The default ...
code_snippets
220331dd-5929-4a16-9d9b-4961a08b2117
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
7
SemanticChunker@1.0.0
fb704ebe9b2b160a69d9d441d58e126d47f73bc62ac048536929cf37d2a3b54b
[Array to CSV > JSON to CSV] ### JSON to CSV Converting **JSON data** to CSV is a simple extension of the previous functions. We can parse the JSON data into an array of objects and then use the `objectToCSV` function to serialize it. ```js const JSONToCSV = (json, headers, omitHeaders) => objectToCSV(JSON.parse(js...
unknown
unknown
[Array to CSV > JSON to CSV] ### JSON to CSV Converting **JSON data** to CSV is a simple extension of the previous functions. We can parse the JSON data into an array of objects and then use the `objectToCSV` function to serialize it. ```js const JSONToCSV = (json, headers, omitHeaders) => objectToCSV(JSON.parse(js...
[Array to CSV > JSON to CSV] ### JSON to CSV Converting **JSON data** to CSV is a simple extension of the previous functions. We can parse the JSON data into an array of objects and then use the `objectToCSV` function to serialize it. ```js const JSONToCSV = (json, headers, omitHeaders) => objectToCSV(JSON.parse(js...
code_snippets
246c5492-5951-461a-bd2b-be535d62d037
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
8
SemanticChunker@1.0.0
8db6f374ddc3132609df13597a4175cbb395b8af8e16f2ad34cd90f52cda8a4c
[Converting to CSV > Parsing CSV] ## Parsing CSV Parsing CSV data back into arrays or objects can be trickier than serialization. The same **edge cases** need to be handled when deserializing the data. Let's focus on **row deserialization** first. While we can use regular expressions for a more elegant solution, we'l...
unknown
unknown
[Converting to CSV > Parsing CSV] ## Parsing CSV Parsing CSV data back into arrays or objects can be trickier than serialization. The same **edge cases** need to be handled when deserializing the data. Let's focus on **row deserialization** first. While we can use regular expressions for a more elegant solution, we'l...
[Converting to CSV > Parsing CSV] ## Parsing CSV Parsing CSV data back into arrays or objects can be trickier than serialization. The same **edge cases** need to be handled when deserializing the data. Let's focus on **row deserialization** first. While we can use regular expressions for a more elegant solution, we'l...
code_snippets
542f9292-3e65-4ef4-8e47-787d15ae981a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
1
SemanticChunker@1.0.0
176898715514684000910c998005f35d03a0e2687a7b1c219c879332967d37ae
[Converting to CSV] ## Converting to CSV **Serializing data** to CSV is generally straightforward. Using `Array.prototype.join()` with a delimiter of your choice, you can easily create a single **row from an array of values**. ```js const serializeRow = (row, delimiter = ',') => row.join(delimiter); serializeRow(['...
unknown
unknown
[Converting to CSV] ## Converting to CSV **Serializing data** to CSV is generally straightforward. Using `Array.prototype.join()` with a delimiter of your choice, you can easily create a single **row from an array of values**. ```js const serializeRow = (row, delimiter = ',') => row.join(delimiter); serializeRow(['...
[Converting to CSV] ## Converting to CSV **Serializing data** to CSV is generally straightforward. Using `Array.prototype.join()` with a delimiter of your choice, you can easily create a single **row from an array of values**. ```js const serializeRow = (row, delimiter = ',') => row.join(delimiter); serializeRow(['...
code_snippets
5b233a23-c9f6-41ed-ad81-af1e1c990a10
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
4
SemanticChunker@1.0.0
38a787a1f49848db877f81bf25bd215d6669479dff86388aded08b6c203d254c
[Array to CSV > Object to CSV] ### Object to CSV Converting JavaScript **objects** to CSV is a bit more involved. As objects contain **key-value pairs**, we need to serialize the values in the correct order based on the keys. We can either use a **predefined list of keys** or **extract them from the objects** themsel...
unknown
unknown
[Array to CSV > Object to CSV] ### Object to CSV Converting JavaScript **objects** to CSV is a bit more involved. As objects contain **key-value pairs**, we need to serialize the values in the correct order based on the keys. We can either use a **predefined list of keys** or **extract them from the objects** themsel...
[Array to CSV > Object to CSV] ### Object to CSV Converting JavaScript **objects** to CSV is a bit more involved. As objects contain **key-value pairs**, we need to serialize the values in the correct order based on the keys. We can either use a **predefined list of keys** or **extract them from the objects** themsel...
code_snippets
61d9f59c-ba7c-4506-8276-6e1c5f9619c4
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
3
SemanticChunker@1.0.0
85c30e504bc57efc2b141becd659ac8c1a03d3cab4666a445880e4113740f9dd
[Converting to CSV > Array to CSV] ### Array to CSV Serializing an **array of values** into CSV is essentially just moving from one dimension to two. We can use `Array.prototype.map()` to serialize each row and then join them together with **newline characters** (`\n`). ```js const arrayToCSV = (arr, delimiter = ','...
unknown
unknown
[Converting to CSV > Array to CSV] ### Array to CSV Serializing an **array of values** into CSV is essentially just moving from one dimension to two. We can use `Array.prototype.map()` to serialize each row and then join them together with **newline characters** (`\n`). ```js const arrayToCSV = (arr, delimiter = ','...
[Converting to CSV > Array to CSV] ### Array to CSV Serializing an **array of values** into CSV is essentially just moving from one dimension to two. We can use `Array.prototype.map()` to serialize each row and then join them together with **newline characters** (`\n`). ```js const arrayToCSV = (arr, delimiter = ','...
code_snippets
83521b4a-fd74-4e08-96cd-979f2d7a3407
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
5
SemanticChunker@1.0.0
3bcce0b3cb996fa959900549a70ce96fa28594cf9bb3f7264d3cda3862d7cd0a
[Object to CSV > Header extraction] #### Header extraction In short, extracting the header row from the objects involves collecting all **unique keys** from the objects. We can achieve this by using `Array.prototype.reduce()` and a `Set` to keep track of the unique keys. ```js const extractHeaders = (arr) => [...ar...
unknown
unknown
[Object to CSV > Header extraction] #### Header extraction In short, extracting the header row from the objects involves collecting all **unique keys** from the objects. We can achieve this by using `Array.prototype.reduce()` and a `Set` to keep track of the unique keys. ```js const extractHeaders = (arr) => [...ar...
[Object to CSV > Header extraction] #### Header extraction In short, extracting the header row from the objects involves collecting all **unique keys** from the objects. We can achieve this by using `Array.prototype.reduce()` and a `Set` to keep track of the unique keys. ```js const extractHeaders = (arr) => [...ar...
code_snippets
9f1ca008-ad6f-443f-a427-f3fdef088d9a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
13
SemanticChunker@1.0.0
3ef058c1dd337168f98bcfa2af98ac188bb579d4b5e6f1151ea7801486c1afb9
[Converting to CSV > Summary] ## Summary This guide covered **most of the groundwork** necessary to convert between CSV data and JavaScript arrays, objects, or JSON. The provided functions can be **customized or extended**, depending on your specific needs. Remember that CSV is **not a standardized format**, so you m...
unknown
unknown
[Converting to CSV > Summary] ## Summary This guide covered **most of the groundwork** necessary to convert between CSV data and JavaScript arrays, objects, or JSON. The provided functions can be **customized or extended**, depending on your specific needs. Remember that CSV is **not a standardized format**, so you m...
[Converting to CSV > Summary] ## Summary This guide covered **most of the groundwork** necessary to convert between CSV data and JavaScript arrays, objects, or JSON. The provided functions can be **customized or extended**, depending on your specific needs. Remember that CSV is **not a standardized format**, so you m...
code_snippets
a0c63558-377f-47dd-b453-f0257ca7804c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
11
SemanticChunker@1.0.0
1e0ee9f5616fbbc1ee8675f3f726d7f9cc4875892e64b1d1a43ade91c27afad2
[Parsing CSV > CSV to object] ### CSV to object Converting CSV data into **objects** needs a couple of extra steps. We need to **extract the header row** to use as keys for the objects. We can then use these keys to create objects for each row. We'll use the same `deserializeRow` function to extract the values for ea...
unknown
unknown
[Parsing CSV > CSV to object] ### CSV to object Converting CSV data into **objects** needs a couple of extra steps. We need to **extract the header row** to use as keys for the objects. We can then use these keys to create objects for each row. We'll use the same `deserializeRow` function to extract the values for ea...
[Parsing CSV > CSV to object] ### CSV to object Converting CSV data into **objects** needs a couple of extra steps. We need to **extract the header row** to use as keys for the objects. We can then use these keys to create objects for each row. We'll use the same `deserializeRow` function to extract the values for ea...
code_snippets
b31838cc-dee7-4580-8ecc-9c0bad122881
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
12
SemanticChunker@1.0.0
05aaead2c148a68c38f1f2a648e57e800ec107b466d9c569be125b86167d9678
[Parsing CSV > CSV to JSON] ### CSV to JSON Converting CSV data into **JSON** is a simple extension of the previous functions. We can use the `CSVtoObject` function to parse the CSV data into objects and then use `JSON.stringify` to serialize it. ```js const CSVToJSON = (data, delimiter = ',') => JSON.stringify(CSV...
unknown
unknown
[Parsing CSV > CSV to JSON] ### CSV to JSON Converting CSV data into **JSON** is a simple extension of the previous functions. We can use the `CSVtoObject` function to parse the CSV data into objects and then use `JSON.stringify` to serialize it. ```js const CSVToJSON = (data, delimiter = ',') => JSON.stringify(CSV...
[Parsing CSV > CSV to JSON] ### CSV to JSON Converting CSV data into **JSON** is a simple extension of the previous functions. We can use the `CSVtoObject` function to parse the CSV data into objects and then use `JSON.stringify` to serialize it. ```js const CSVToJSON = (data, delimiter = ',') => JSON.stringify(CSV...
code_snippets
c1819a3b-5969-4393-bb28-d1a55c7d0582
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
9
SemanticChunker@1.0.0
1672e118197f9419e45eba5c9e8f941eca7b28234fadd5fb27a7c531cecab1ee
[Converting to CSV > Parsing CSV] Having a function to deserialize a single row, we can now move on to deserializing the whole CSV data. We'll split the data into rows and use the `deserializeRow` function to extract the values. > [!NOTE] > > **All values are strings after deserialization**. To convert them back to t...
unknown
unknown
[Converting to CSV > Parsing CSV] Having a function to deserialize a single row, we can now move on to deserializing the whole CSV data. We'll split the data into rows and use the `deserializeRow` function to extract the values. > [!NOTE] > > **All values are strings after deserialization**. To convert them back to t...
[Converting to CSV > Parsing CSV] Having a function to deserialize a single row, we can now move on to deserializing the whole CSV data. We'll split the data into rows and use the `deserializeRow` function to extract the values. > [!NOTE] > > **All values are strings after deserialization**. To convert them back to t...
code_snippets
c45077b5-68a1-401d-9886-d3a2205afdcd
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
10
SemanticChunker@1.0.0
87f7e083379202981b7e3af0cf29a6f572524444234038ef1baa1bbadef8d7a7
[Parsing CSV > CSV to array] ### CSV to array The previous function is a good starting point for deserializing CSV data into **arrays**. However, we might want to **omit the header row**. We can add an optional argument to the function to handle this. ```js const CSVToArray = (data, delimiter = ',', omitHeader = fal...
unknown
unknown
[Parsing CSV > CSV to array] ### CSV to array The previous function is a good starting point for deserializing CSV data into **arrays**. However, we might want to **omit the header row**. We can add an optional argument to the function to handle this. ```js const CSVToArray = (data, delimiter = ',', omitHeader = fal...
[Parsing CSV > CSV to array] ### CSV to array The previous function is a good starting point for deserializing CSV data into **arrays**. However, we might want to **omit the header row**. We can add an optional argument to the function to handle this. ```js const CSVToArray = (data, delimiter = ',', omitHeader = fal...
code_snippets
cbc85ed9-38d8-4efb-b43d-67bc9d69955d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
0
SemanticChunker@1.0.0
162886beaf41d359cb6e470f9b86c12048ff7b86204a7818b21362fa5b601daf
--- title: Convert between CSV and JavaScript arrays, objects or JSON shortTitle: Convert between CSV and array, object or JSON language: javascript tags: [array,object,string] cover: tropical-bike excerpt: Serialize and deserialize CSV data in JavaScript with this in-depth guide. listed: true dateModified: 2024-06-08 ...
unknown
unknown
--- title: Convert between CSV and JavaScript arrays, objects or JSON shortTitle: Convert between CSV and array, object or JSON language: javascript tags: [array,object,string] cover: tropical-bike excerpt: Serialize and deserialize CSV data in JavaScript with this in-depth guide. listed: true dateModified: 2024-06-08 ...
--- title: Convert between CSV and JavaScript arrays, objects or JSON shortTitle: Convert between CSV and array, object or JSON language: javascript tags: [array,object,string] cover: tropical-bike excerpt: Serialize and deserialize CSV data in JavaScript with this in-depth guide. listed: true dateModified: 2024-06-08 ...
code_snippets
e6d3c2eb-3807-41d1-af38-c9881ccd2c16
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
14
SemanticChunker@1.0.0
4fa4ac4c31776f2403fd2dc320d234edb599ca9c9ec8747ba2baacad5c74c411
[Converting to CSV > Summary] ``` ```js title="deserializeCSV.js" const deserializeRow = (row, delimiter = ',') => { const values = []; let index = 0, matchStart = 0, isInsideQuotations = false; while (true) { if (index === row.length) { values.push(row.slice(matchStart, index)); break; } const char = row[ind...
unknown
unknown
[Converting to CSV > Summary] ``` ```js title="deserializeCSV.js" const deserializeRow = (row, delimiter = ',') => { const values = []; let index = 0, matchStart = 0, isInsideQuotations = false; while (true) { if (index === row.length) { values.push(row.slice(matchStart, index)); break; } const char = row[ind...
[Converting to CSV > Summary] ``` ```js title="deserializeCSV.js" const deserializeRow = (row, delimiter = ',') => { const values = []; let index = 0, matchStart = 0, isInsideQuotations = false; while (true) { if (index === row.length) { values.push(row.slice(matchStart, index)); break; } const char = row[ind...
code_snippets
f009aee5-66da-406b-9b62-34f1f1b4bf60
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/convert-csv-to-array-object-or-json.md
unknown
01007903-e975-444a-aff9-b044d3b02a2e
2
SemanticChunker@1.0.0
8c2960881a59a2fc61efd9c7591292c43672f086626e9c9f8b714963dee37fc1
[Converting to CSV] ```js const isEmptyValue = value => value === null || value === undefined || Number.isNaN(value); const serializeValue = (value, delimiter = ',') => { if (isEmptyValue(value)) return ''; value = `${value}`; if ( value.includes(delimiter) || value.includes('\n') || value.includes('"') ) re...
unknown
unknown
[Converting to CSV] ```js const isEmptyValue = value => value === null || value === undefined || Number.isNaN(value); const serializeValue = (value, delimiter = ',') => { if (isEmptyValue(value)) return ''; value = `${value}`; if ( value.includes(delimiter) || value.includes('\n') || value.includes('"') ) re...
[Converting to CSV] ```js const isEmptyValue = value => value === null || value === undefined || Number.isNaN(value); const serializeValue = (value, delimiter = ',') => { if (isEmptyValue(value)) return ''; value = `${value}`; if ( value.includes(delimiter) || value.includes('\n') || value.includes('"') ) re...
code_snippets
cf804ad9-f3a3-4c50-b70d-22914cd8e31c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/current-url.md
unknown
00eb1418-9243-4727-9a64-65a96e6673aa
0
SemanticChunker@1.0.0
421bf07e54af7612be6508eca8cc260e77be904bef13c600bca98c467ad8beac
--- title: How can I get the current URL in JavaScript? shortTitle: Current URL language: javascript tags: [browser] cover: purple-sunset-waves excerpt: Learn a simple way to get the browser's current URL in JavaScript. listed: true dateModified: 2023-10-19 --- As mentioned in the [Window.location Cheat Sheet](/js/s/w...
unknown
unknown
--- title: How can I get the current URL in JavaScript? shortTitle: Current URL language: javascript tags: [browser] cover: purple-sunset-waves excerpt: Learn a simple way to get the browser's current URL in JavaScript. listed: true dateModified: 2023-10-19 --- As mentioned in the [Window.location Cheat Sheet](/js/s/w...
--- title: How can I get the current URL in JavaScript? shortTitle: Current URL language: javascript tags: [browser] cover: purple-sunset-waves excerpt: Learn a simple way to get the browser's current URL in JavaScript. listed: true dateModified: 2023-10-19 --- As mentioned in the [Window.location Cheat Sheet](/js/s/w...
code_snippets
e28128d9-6af0-4991-b960-37fc3174f99c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/create-html-elements.md
unknown
a9a558d7-113f-43bc-a5fc-c06fa3c3af2a
0
SemanticChunker@1.0.0
f7e41e2df3de6da80fc45dafb0017be64b6f38055e6d38c8abb564701a7bc515
--- title: Creating HTML elements in JavaScript shortTitle: Creating HTML elements language: javascript tags: [browser] cover: body-of-water excerpt: Learn how to create HTML elements in JavaScript, by abstracting the creation logic into a function. listed: true dateModified: 2022-05-29 --- JavaScript's `Document.crea...
unknown
unknown
--- title: Creating HTML elements in JavaScript shortTitle: Creating HTML elements language: javascript tags: [browser] cover: body-of-water excerpt: Learn how to create HTML elements in JavaScript, by abstracting the creation logic into a function. listed: true dateModified: 2022-05-29 --- JavaScript's `Document.crea...
--- title: Creating HTML elements in JavaScript shortTitle: Creating HTML elements language: javascript tags: [browser] cover: body-of-water excerpt: Learn how to create HTML elements in JavaScript, by abstracting the creation logic into a function. listed: true dateModified: 2022-05-29 --- JavaScript's `Document.crea...
code_snippets
44ffaa71-70ba-4cda-b228-f99a1c5a55d2
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/count-occurrences.md
unknown
255380e9-1532-419a-bc23-c4b27b7e9b57
0
SemanticChunker@1.0.0
6277449adaede635069dd56cf41f997b3098108b5429e737b57cd3db9e6219f5
--- title: Count the occurrences of a value in a JavaScript array or string shortTitle: Count occurrences language: javascript tags: [array,string] cover: dark-leaves-4 excerpt: Given a value, find out how many times it appears in an array or string. listed: true dateModified: 2024-05-14 --- I've often had a need to c...
unknown
unknown
--- title: Count the occurrences of a value in a JavaScript array or string shortTitle: Count occurrences language: javascript tags: [array,string] cover: dark-leaves-4 excerpt: Given a value, find out how many times it appears in an array or string. listed: true dateModified: 2024-05-14 --- I've often had a need to c...
--- title: Count the occurrences of a value in a JavaScript array or string shortTitle: Count occurrences language: javascript tags: [array,string] cover: dark-leaves-4 excerpt: Given a value, find out how many times it appears in an array or string. listed: true dateModified: 2024-05-14 --- I've often had a need to c...
code_snippets
475ce1e3-8952-43d3-8540-b1d43d4f1938
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/count-occurrences.md
unknown
255380e9-1532-419a-bc23-c4b27b7e9b57
2
SemanticChunker@1.0.0
9666672ffc66e3f1c64f4c196b6cf4708a6bc9f2e175afaf9cd772dce8695e1f
[Count value occurrences in an array > Count value occurrences in a string] ## Count value occurrences in a string Counting the occurrences of a value in a **string** is a bit more complex than in an array. You can use `Array.prototype.indexOf()` to look for the value in the string and increment a counter each time i...
unknown
unknown
[Count value occurrences in an array > Count value occurrences in a string] ## Count value occurrences in a string Counting the occurrences of a value in a **string** is a bit more complex than in an array. You can use `Array.prototype.indexOf()` to look for the value in the string and increment a counter each time i...
[Count value occurrences in an array > Count value occurrences in a string] ## Count value occurrences in a string Counting the occurrences of a value in a **string** is a bit more complex than in an array. You can use `Array.prototype.indexOf()` to look for the value in the string and increment a counter each time i...
code_snippets
b6878afc-a196-487d-b9c4-1f268c1d7454
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/count-occurrences.md
unknown
255380e9-1532-419a-bc23-c4b27b7e9b57
1
SemanticChunker@1.0.0
29b52d81086c835cc4830450ffa1ceef433fe5c3c1554a1a3d06ba825de53962
[Count value occurrences in an array] ## Count value occurrences in an array `Array.prototype.reduce()` provides the most straightforward way to count the occurrences of a value in an **array**. Simply increment a counter each time the specific value is encountered inside the array and return the final count. ```js ...
unknown
unknown
[Count value occurrences in an array] ## Count value occurrences in an array `Array.prototype.reduce()` provides the most straightforward way to count the occurrences of a value in an **array**. Simply increment a counter each time the specific value is encountered inside the array and return the final count. ```js ...
[Count value occurrences in an array] ## Count value occurrences in an array `Array.prototype.reduce()` provides the most straightforward way to count the occurrences of a value in an **array**. Simply increment a counter each time the specific value is encountered inside the array and return the final count. ```js ...
code_snippets
3006b306-fe1b-4dc8-852a-f1f7234cba03
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/count-grouped-elements.md
unknown
eca89464-3ece-4a35-aa40-e18f88c8222f
3
SemanticChunker@1.0.0
ee844bef00d5a3c3d3f37dd3136dc31163aca12c95812cac7b5ad5f077b1e9aa
[Count the occurrences of each value in an array > Using a `Map` instead of an object] ## Using a `Map` instead of an object Both of the previous examples use **objects** to store the frequencies of the values. However, you can also use a `Map` to store the frequencies. This can be useful if you need to **keep the in...
unknown
unknown
[Count the occurrences of each value in an array > Using a `Map` instead of an object] ## Using a `Map` instead of an object Both of the previous examples use **objects** to store the frequencies of the values. However, you can also use a `Map` to store the frequencies. This can be useful if you need to **keep the in...
[Count the occurrences of each value in an array > Using a `Map` instead of an object] ## Using a `Map` instead of an object Both of the previous examples use **objects** to store the frequencies of the values. However, you can also use a `Map` to store the frequencies. This can be useful if you need to **keep the in...
code_snippets
74073d7b-7619-42c9-877b-3223c9f2f981
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/count-grouped-elements.md
unknown
eca89464-3ece-4a35-aa40-e18f88c8222f
2
SemanticChunker@1.0.0
c92cdcb9ac4eeea97908e8ad6fc55b953a947b73f716359991f76917a4699e27
[Count the occurrences of each value in an array > Group the elements of an array based on a function] ## Group the elements of an array based on a function You can also **group the elements** of an array based on a given function and return the count of elements in each group. This can be useful when you want to gro...
unknown
unknown
[Count the occurrences of each value in an array > Group the elements of an array based on a function] ## Group the elements of an array based on a function You can also **group the elements** of an array based on a given function and return the count of elements in each group. This can be useful when you want to gro...
[Count the occurrences of each value in an array > Group the elements of an array based on a function] ## Group the elements of an array based on a function You can also **group the elements** of an array based on a given function and return the count of elements in each group. This can be useful when you want to gro...
code_snippets
82b18283-a29c-42a6-b44f-5745f0bd9b3f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/count-grouped-elements.md
unknown
eca89464-3ece-4a35-aa40-e18f88c8222f
4
SemanticChunker@1.0.0
6cc2808748c43061722f69e48633c6c448a568a5c9ef8aa873ee27915aa1b123
[Count the occurrences of each value in an array > Implement a frequency map data structure] ## Implement a frequency map data structure When dealing with **data that changes often**, you may need to recalculate frequencies as needed. This can become tedious and inefficient, especially if you only need to keep track ...
unknown
unknown
[Count the occurrences of each value in an array > Implement a frequency map data structure] ## Implement a frequency map data structure When dealing with **data that changes often**, you may need to recalculate frequencies as needed. This can become tedious and inefficient, especially if you only need to keep track ...
[Count the occurrences of each value in an array > Implement a frequency map data structure] ## Implement a frequency map data structure When dealing with **data that changes often**, you may need to recalculate frequencies as needed. This can become tedious and inefficient, especially if you only need to keep track ...
code_snippets
8b999338-de8b-4429-be42-58268d7266d5
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/count-grouped-elements.md
unknown
eca89464-3ece-4a35-aa40-e18f88c8222f
1
SemanticChunker@1.0.0
58160bb43c40f3eaf1063ab4dd301366b786434c79b7eefbd342d1e07951b1b4
[Count the occurrences of each value in an array] ## Count the occurrences of each value in an array You can use `Array.prototype.reduce()` to create an object with the unique values of an array as keys and their **frequencies** as the values. Use the nullish coalescing operator (`??`) to initialize the value of each...
unknown
unknown
[Count the occurrences of each value in an array] ## Count the occurrences of each value in an array You can use `Array.prototype.reduce()` to create an object with the unique values of an array as keys and their **frequencies** as the values. Use the nullish coalescing operator (`??`) to initialize the value of each...
[Count the occurrences of each value in an array] ## Count the occurrences of each value in an array You can use `Array.prototype.reduce()` to create an object with the unique values of an array as keys and their **frequencies** as the values. Use the nullish coalescing operator (`??`) to initialize the value of each...
code_snippets
b2723ec8-3785-43ab-849c-832c1ddc795a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/count-grouped-elements.md
unknown
eca89464-3ece-4a35-aa40-e18f88c8222f
0
SemanticChunker@1.0.0
3dfab30342cc2521c796cfae1fcb5e71a246e21639719e960bf30e661decaabf
--- title: How can I group and count values in a JavaScript array? shortTitle: Group and count values language: javascript tags: [array,object] cover: tropical-waterfall excerpt: Learn how to group and count the values of a JavaScript array using simple array methods. listed: true dateModified: 2024-08-19 --- Finding ...
unknown
unknown
--- title: How can I group and count values in a JavaScript array? shortTitle: Group and count values language: javascript tags: [array,object] cover: tropical-waterfall excerpt: Learn how to group and count the values of a JavaScript array using simple array methods. listed: true dateModified: 2024-08-19 --- Finding ...
--- title: How can I group and count values in a JavaScript array? shortTitle: Group and count values language: javascript tags: [array,object] cover: tropical-waterfall excerpt: Learn how to group and count the values of a JavaScript array using simple array methods. listed: true dateModified: 2024-08-19 --- Finding ...
code_snippets
f7c5eda1-6bb0-48e5-8c3a-b318a5bd7aba
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/count-grouped-elements.md
unknown
eca89464-3ece-4a35-aa40-e18f88c8222f
5
SemanticChunker@1.0.0
c89deb9927bd57ba433c05ff578a321810256941aeb12005608f5b8148e5b52a
[Count the occurrences of each value in an array > Implement a frequency map data structure] Leveraging the built-in `Map` class via the use of **inheritance**, we implement `get()` in such a way that **non-existent values** will return `0`. Similarly, we implement `has()` to check if the frequency of a value is great...
unknown
unknown
[Count the occurrences of each value in an array > Implement a frequency map data structure] Leveraging the built-in `Map` class via the use of **inheritance**, we implement `get()` in such a way that **non-existent values** will return `0`. Similarly, we implement `has()` to check if the frequency of a value is great...
[Count the occurrences of each value in an array > Implement a frequency map data structure] Leveraging the built-in `Map` class via the use of **inheritance**, we implement `get()` in such a way that **non-existent values** will return `0`. Similarly, we implement `has()` to check if the frequency of a value is great...
code_snippets
12616395-221a-445b-bc50-2bec98afd64a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/create-element.md
unknown
54f8e37b-3db3-4acd-a119-bc5a7ec1df0f
0
SemanticChunker@1.0.0
9eefeb8790f90142828058d2438de8f5cf7f1a580e7f8e569e0f667917b82aa8
--- title: Create an HTML element with JavaScript shortTitle: Create HTML element language: javascript tags: [browser] cover: flower-portrait-4 excerpt: If you want to create an element from a string without appending it to the document, you can use a few lines of JavaScript. listed: true dateModified: 2024-07-05 --- ...
unknown
unknown
--- title: Create an HTML element with JavaScript shortTitle: Create HTML element language: javascript tags: [browser] cover: flower-portrait-4 excerpt: If you want to create an element from a string without appending it to the document, you can use a few lines of JavaScript. listed: true dateModified: 2024-07-05 --- ...
--- title: Create an HTML element with JavaScript shortTitle: Create HTML element language: javascript tags: [browser] cover: flower-portrait-4 excerpt: If you want to create an element from a string without appending it to the document, you can use a few lines of JavaScript. listed: true dateModified: 2024-07-05 --- ...
code_snippets
09290898-340d-4941-9d46-5975169fa3ee
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-binary-search-tree.md
unknown
6aae2aab-bceb-40e6-b332-f8e3b61ee8c8
1
SemanticChunker@1.0.0
5a221a000c532bb25bc82c4cf7acf696a4e95e726ef334791cc0a5b441c9a24b
[Definition] ## Definition A binary search tree is a data structure consisting of a set of ordered linked nodes that represent a hierarchical tree structure. Each node is linked to others via parent-children relationship. Any given node can have at most two children (left and right). The first node in the binary sear...
unknown
unknown
[Definition] ## Definition A binary search tree is a data structure consisting of a set of ordered linked nodes that represent a hierarchical tree structure. Each node is linked to others via parent-children relationship. Any given node can have at most two children (left and right). The first node in the binary sear...
[Definition] ## Definition A binary search tree is a data structure consisting of a set of ordered linked nodes that represent a hierarchical tree structure. Each node is linked to others via parent-children relationship. Any given node can have at most two children (left and right). The first node in the binary sear...
code_snippets
24e6608b-cb56-4d38-ae2e-ba60ee64e718
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-binary-search-tree.md
unknown
6aae2aab-bceb-40e6-b332-f8e3b61ee8c8
4
SemanticChunker@1.0.0
de1aa5b057e4a2e503051bf68053f338000f739aa2cd9059eee523c944f2850c
[Definition > Implementation] - Create a `class` for the `BinarySearchTreeNode` with a `constructor` that initializes the appropriate `key`, `value`, `parent`, `left` and `right` properties. - Define an `isLeaf` getter, that uses `Array.prototype.length` to check if both `left` and `right` are empty. - Define a `hasCh...
unknown
unknown
[Definition > Implementation] - Create a `class` for the `BinarySearchTreeNode` with a `constructor` that initializes the appropriate `key`, `value`, `parent`, `left` and `right` properties. - Define an `isLeaf` getter, that uses `Array.prototype.length` to check if both `left` and `right` are empty. - Define a `hasCh...
[Definition > Implementation] - Create a `class` for the `BinarySearchTreeNode` with a `constructor` that initializes the appropriate `key`, `value`, `parent`, `left` and `right` properties. - Define an `isLeaf` getter, that uses `Array.prototype.length` to check if both `left` and `right` are empty. - Define a `hasCh...
code_snippets
5ba8b48e-5e6d-4ffe-acd9-05f54daff5e4
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-binary-search-tree.md
unknown
6aae2aab-bceb-40e6-b332-f8e3b61ee8c8
2
SemanticChunker@1.0.0
f6ce3d7fff23c61e29d58dc084df6cb7027c12504f08a00afb70c0e24199217d
[Definition > Implementation] ## Implementation ```js class BinarySearchTreeNode { constructor(key, value = key, parent = null) { this.key = key; this.value = value; this.parent = parent; this.left = null; this.right = null; } get isLeaf() { return this.left === null && this.right === null; } get hasChil...
unknown
unknown
[Definition > Implementation] ## Implementation ```js class BinarySearchTreeNode { constructor(key, value = key, parent = null) { this.key = key; this.value = value; this.parent = parent; this.left = null; this.right = null; } get isLeaf() { return this.left === null && this.right === null; } get hasChil...
[Definition > Implementation] ## Implementation ```js class BinarySearchTreeNode { constructor(key, value = key, parent = null) { this.key = key; this.value = value; this.parent = parent; this.left = null; this.right = null; } get isLeaf() { return this.left === null && this.right === null; } get hasChil...
code_snippets
5eaaaa41-ed17-4ca2-a267-5734b8ccd49a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-binary-search-tree.md
unknown
6aae2aab-bceb-40e6-b332-f8e3b61ee8c8
0
SemanticChunker@1.0.0
47a7a87ffddd0b340f094d50d38939832955abec402a7fb472603729952c4cd6
--- title: JavaScript Data Structures - Binary Search Tree shortTitle: Binary Search Tree language: javascript tags: [class] cover: purple-flower-macro-4 excerpt: A binary search tree is a hierarchical data structure of ordered nodes with at most two children each. listed: true dateModified: 2021-08-31 ---
unknown
unknown
--- title: JavaScript Data Structures - Binary Search Tree shortTitle: Binary Search Tree language: javascript tags: [class] cover: purple-flower-macro-4 excerpt: A binary search tree is a hierarchical data structure of ordered nodes with at most two children each. listed: true dateModified: 2021-08-31 ---
--- title: JavaScript Data Structures - Binary Search Tree shortTitle: Binary Search Tree language: javascript tags: [class] cover: purple-flower-macro-4 excerpt: A binary search tree is a hierarchical data structure of ordered nodes with at most two children each. listed: true dateModified: 2021-08-31 ---
code_snippets
8cc97940-f81b-4cab-8500-aa051c8c7ce9
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-binary-search-tree.md
unknown
6aae2aab-bceb-40e6-b332-f8e3b61ee8c8
5
SemanticChunker@1.0.0
69cf4f03ca4a1ecfa5fc4f0d07b1971675bab199a0bb51a011641aa76f0da5e5
[Definition > Implementation] ```js const tree = new BinarySearchTree(30); tree.insert(10); tree.insert(15); tree.insert(12); tree.insert(40); tree.insert(35); tree.insert(50); [...tree.preOrderTraversal()].map(x => x.value); // [30, 10, 15, 12, 40, 35, 50] [...tree.inOrderTraversal()].map(x => x.value); // [10, 12...
unknown
unknown
[Definition > Implementation] ```js const tree = new BinarySearchTree(30); tree.insert(10); tree.insert(15); tree.insert(12); tree.insert(40); tree.insert(35); tree.insert(50); [...tree.preOrderTraversal()].map(x => x.value); // [30, 10, 15, 12, 40, 35, 50] [...tree.inOrderTraversal()].map(x => x.value); // [10, 12...
[Definition > Implementation] ```js const tree = new BinarySearchTree(30); tree.insert(10); tree.insert(15); tree.insert(12); tree.insert(40); tree.insert(35); tree.insert(50); [...tree.preOrderTraversal()].map(x => x.value); // [30, 10, 15, 12, 40, 35, 50] [...tree.inOrderTraversal()].map(x => x.value); // [10, 12...
code_snippets
e33fbaa2-4e62-403e-b362-6f8322b41556
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-binary-search-tree.md
unknown
6aae2aab-bceb-40e6-b332-f8e3b61ee8c8
3
SemanticChunker@1.0.0
5733a7fd4512e83e7cd7498fac15f96ebf1d34c305ba32302404da7869f7c208
[Definition > Implementation] ```js // [continued: part 1] class BinarySearchTree { constructor(key, value = key) { this.root = new BinarySearchTreeNode(key, value); } *inOrderTraversal(node = this.root) { if (node.left) yield* this.inOrderTraversal(node.left); yield node; if (node.right) yield* this.inOrderTr...
unknown
unknown
[Definition > Implementation] ```js // [continued: part 1] class BinarySearchTree { constructor(key, value = key) { this.root = new BinarySearchTreeNode(key, value); } *inOrderTraversal(node = this.root) { if (node.left) yield* this.inOrderTraversal(node.left); yield node; if (node.right) yield* this.inOrderTr...
[Definition > Implementation] ```js // [continued: part 1] class BinarySearchTree { constructor(key, value = key) { this.root = new BinarySearchTreeNode(key, value); } *inOrderTraversal(node = this.root) { if (node.left) yield* this.inOrderTraversal(node.left); yield node; if (node.right) yield* this.inOrderTr...
code_snippets
43b7be42-aec1-469b-b3bd-368221a72361
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/create-directory-if-not-exists.md
unknown
5231a983-6924-4d29-8c9a-556a533e49bb
0
SemanticChunker@1.0.0
60aa9bee28dab7d9480b1e737df29a4f48eea303b942c9ce533d78b228f35e5c
--- title: Create a directory if it doesn't exist using Node.js shortTitle: Create directory if not exists language: javascript tags: [node] cover: misty-mountains excerpt: Learn how to create a directory using Node.js, if it doesn't exist. listed: true dateModified: 2024-03-08 --- When working with files and director...
unknown
unknown
--- title: Create a directory if it doesn't exist using Node.js shortTitle: Create directory if not exists language: javascript tags: [node] cover: misty-mountains excerpt: Learn how to create a directory using Node.js, if it doesn't exist. listed: true dateModified: 2024-03-08 --- When working with files and director...
--- title: Create a directory if it doesn't exist using Node.js shortTitle: Create directory if not exists language: javascript tags: [node] cover: misty-mountains excerpt: Learn how to create a directory using Node.js, if it doesn't exist. listed: true dateModified: 2024-03-08 --- When working with files and director...
code_snippets
4a6f7775-7e54-4ee3-82e2-84ef27f324d8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/create-directory-if-not-exists.md
unknown
5231a983-6924-4d29-8c9a-556a533e49bb
1
SemanticChunker@1.0.0
40ff90f06973fc10408faf0ddff4a7668bb9b13a49ca84dc1b9a2fd6807e846b
[Asynchronous approach] ## Asynchronous approach Most commonly, you'll want to create a directory asynchronously, using `fs.mkdir()`. This method returns a `Promise`, that will reject if the directory already exists. In order to remedy that, we can use `fs.access()` to check if the directory exists, and then create i...
unknown
unknown
[Asynchronous approach] ## Asynchronous approach Most commonly, you'll want to create a directory asynchronously, using `fs.mkdir()`. This method returns a `Promise`, that will reject if the directory already exists. In order to remedy that, we can use `fs.access()` to check if the directory exists, and then create i...
[Asynchronous approach] ## Asynchronous approach Most commonly, you'll want to create a directory asynchronously, using `fs.mkdir()`. This method returns a `Promise`, that will reject if the directory already exists. In order to remedy that, we can use `fs.access()` to check if the directory exists, and then create i...
code_snippets
c5f6ce7b-7bb1-4a35-8eb3-cb9e60b1c933
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/create-directory-if-not-exists.md
unknown
5231a983-6924-4d29-8c9a-556a533e49bb
2
SemanticChunker@1.0.0
c7cdee2e9277c7954428396fce1752c911b073dd0e8a0b52f309a793fccde07b
[Asynchronous approach > Synchronous approach] ## Synchronous approach While the asynchronous approach is generally preferred, you might want to create a directory synchronously in some cases. You can use `fs.existsSync()` to check if the directory exists, and `fs.mkdirSync()` to create it. ```js import { existsSync...
unknown
unknown
[Asynchronous approach > Synchronous approach] ## Synchronous approach While the asynchronous approach is generally preferred, you might want to create a directory synchronously in some cases. You can use `fs.existsSync()` to check if the directory exists, and `fs.mkdirSync()` to create it. ```js import { existsSync...
[Asynchronous approach > Synchronous approach] ## Synchronous approach While the asynchronous approach is generally preferred, you might want to create a directory synchronously in some cases. You can use `fs.existsSync()` to check if the directory exists, and `fs.mkdirSync()` to create it. ```js import { existsSync...
code_snippets
34827b7d-dcfa-4162-b3dc-34cad77125bb
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/cors-explained.md
unknown
90cd3dc9-6e2f-4046-98bd-979b540d7d6b
0
SemanticChunker@1.0.0
b9c970db5e4bc36ce21543ee13ee70c049401503c36f41b372d2b915ee9f740c
--- title: What is CORS? shortTitle: CORS explained language: javascript tags: [browser,webdev] cover: chill-surfing excerpt: CORS (Cross-Origin Resource Sharing) trips up many developers, but it's pretty easy to wrap your head around. listed: true dateModified: 2023-05-07 --- When it comes to HTTP, an **origin** is d...
unknown
unknown
--- title: What is CORS? shortTitle: CORS explained language: javascript tags: [browser,webdev] cover: chill-surfing excerpt: CORS (Cross-Origin Resource Sharing) trips up many developers, but it's pretty easy to wrap your head around. listed: true dateModified: 2023-05-07 --- When it comes to HTTP, an **origin** is d...
--- title: What is CORS? shortTitle: CORS explained language: javascript tags: [browser,webdev] cover: chill-surfing excerpt: CORS (Cross-Origin Resource Sharing) trips up many developers, but it's pretty easy to wrap your head around. listed: true dateModified: 2023-05-07 --- When it comes to HTTP, an **origin** is d...
code_snippets
dd1cbd14-53f8-46e5-99e4-38e43bcdf839
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/cors-explained.md
unknown
90cd3dc9-6e2f-4046-98bd-979b540d7d6b
1
SemanticChunker@1.0.0
2bb6fbad8ef3030e8ab23a7877d1bb2ed083e2dcd91ac1b2791fecd50bb33aee
As this can be quite restrictive, CORS allows the server to specify which other domains are allowed to make requests to its resources. This is done through the use of **CORS headers**, `Origin` in the request and `Access-Control-Allow-Origin` in the response. This way, for example, API servers can allow requests from s...
unknown
unknown
As this can be quite restrictive, CORS allows the server to specify which other domains are allowed to make requests to its resources. This is done through the use of **CORS headers**, `Origin` in the request and `Access-Control-Allow-Origin` in the response. This way, for example, API servers can allow requests from s...
As this can be quite restrictive, CORS allows the server to specify which other domains are allowed to make requests to its resources. This is done through the use of **CORS headers**, `Origin` in the request and `Access-Control-Allow-Origin` in the response. This way, for example, API servers can allow requests from s...
code_snippets
a00f52f0-e907-4ad9-8ed8-840a0077f407
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-text-to-clipboard.md
unknown
db17a266-1853-4535-b534-3ce335b3396a
2
SemanticChunker@1.0.0
86b1c11930dbb2c2fa67121c83a7c149fb619295de21b0f3611f6733898e879f
[The Asynchronous Clipboard API > Using `Document.execCommand('copy')`] ## Using `Document.execCommand('copy')` While support for the Clipboard API is pretty high across the board, you might need a fallback if you have to **support older browsers**. If that's the case, you can use [`Document.execCommand('copy')`](htt...
unknown
unknown
[The Asynchronous Clipboard API > Using `Document.execCommand('copy')`] ## Using `Document.execCommand('copy')` While support for the Clipboard API is pretty high across the board, you might need a fallback if you have to **support older browsers**. If that's the case, you can use [`Document.execCommand('copy')`](htt...
[The Asynchronous Clipboard API > Using `Document.execCommand('copy')`] ## Using `Document.execCommand('copy')` While support for the Clipboard API is pretty high across the board, you might need a fallback if you have to **support older browsers**. If that's the case, you can use [`Document.execCommand('copy')`](htt...
code_snippets
a917cf49-ba6e-4817-9f9f-1bfdcedc5311
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-text-to-clipboard.md
unknown
db17a266-1853-4535-b534-3ce335b3396a
0
SemanticChunker@1.0.0
8406be3fab5e327c30ba9b7918f4e218d56777a8fd21206f62f6c62644345e7f
--- title: How can I copy text to clipboard with JavaScript? shortTitle: Copy text to clipboard language: javascript tags: [browser] cover: typing excerpt: Learn how to programmatically copy text to clipboard with a few lines of JavaScript and level up your web development skills. listed: true dateModified: 2024-01-13 ...
unknown
unknown
--- title: How can I copy text to clipboard with JavaScript? shortTitle: Copy text to clipboard language: javascript tags: [browser] cover: typing excerpt: Learn how to programmatically copy text to clipboard with a few lines of JavaScript and level up your web development skills. listed: true dateModified: 2024-01-13 ...
--- title: How can I copy text to clipboard with JavaScript? shortTitle: Copy text to clipboard language: javascript tags: [browser] cover: typing excerpt: Learn how to programmatically copy text to clipboard with a few lines of JavaScript and level up your web development skills. listed: true dateModified: 2024-01-13 ...
code_snippets
d4ec7807-8c5d-47a0-b240-2a3f03192f40
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/copy-text-to-clipboard.md
unknown
db17a266-1853-4535-b534-3ce335b3396a
1
SemanticChunker@1.0.0
7bbd03ccc72ee3294c7ffc5186ac64d772a1dc4bac307375bb5e7a4e74b5c817
[The Asynchronous Clipboard API] ## The Asynchronous Clipboard API <baseline-support featureId="async-clipboard"> </baseline-support> Full support for the Clipboard API still isn't here at the time of writing (January, 2024), but you can at least use it to write to the clipboard. Thankfully, that's all you really ne...
unknown
unknown
[The Asynchronous Clipboard API] ## The Asynchronous Clipboard API <baseline-support featureId="async-clipboard"> </baseline-support> Full support for the Clipboard API still isn't here at the time of writing (January, 2024), but you can at least use it to write to the clipboard. Thankfully, that's all you really ne...
[The Asynchronous Clipboard API] ## The Asynchronous Clipboard API <baseline-support featureId="async-clipboard"> </baseline-support> Full support for the Clipboard API still isn't here at the time of writing (January, 2024), but you can at least use it to write to the clipboard. Thankfully, that's all you really ne...
code_snippets
61888f97-204c-4d71-880c-b241926ab60f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/currying.md
unknown
fe91081a-f9ec-473f-9a9b-0dbb6ddbb1ae
2
SemanticChunker@1.0.0
72312c3f28adee572e8a8b7d2ad89ef8e8b48d12cb27de3583fede9cf0f1399f
[Currying a function > Working with variadic functions] ### Working with variadic functions **Variadic functions** are functions that accept a variable number of arguments. For example, `Math.min()` is a variadic function that returns the smallest of zero or more numbers. > [!NOTE] > > `Math.min.length` is 2, which ...
unknown
unknown
[Currying a function > Working with variadic functions] ### Working with variadic functions **Variadic functions** are functions that accept a variable number of arguments. For example, `Math.min()` is a variadic function that returns the smallest of zero or more numbers. > [!NOTE] > > `Math.min.length` is 2, which ...
[Currying a function > Working with variadic functions] ### Working with variadic functions **Variadic functions** are functions that accept a variable number of arguments. For example, `Math.min()` is a variadic function that returns the smallest of zero or more numbers. > [!NOTE] > > `Math.min.length` is 2, which ...
code_snippets
652bf6e3-3129-4baa-8122-65605813998f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/currying.md
unknown
fe91081a-f9ec-473f-9a9b-0dbb6ddbb1ae
1
SemanticChunker@1.0.0
2300ef12c85f1a6ba83714d558aa081dd6c42fbb6fb34abb51fda1169c80e477
[Currying a function] ## Currying a function Creating a `curry()` function can be tricky in some cases. For the sake of simplicity, let's start with a function whose **number of arguments** is **fixed**. In that case, we will use `Function.prototype.length` to determine the number of arguments the function accepts. ...
unknown
unknown
[Currying a function] ## Currying a function Creating a `curry()` function can be tricky in some cases. For the sake of simplicity, let's start with a function whose **number of arguments** is **fixed**. In that case, we will use `Function.prototype.length` to determine the number of arguments the function accepts. ...
[Currying a function] ## Currying a function Creating a `curry()` function can be tricky in some cases. For the sake of simplicity, let's start with a function whose **number of arguments** is **fixed**. In that case, we will use `Function.prototype.length` to determine the number of arguments the function accepts. ...
code_snippets
87451458-ee12-42ca-8294-90d0176191a4
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/currying.md
unknown
fe91081a-f9ec-473f-9a9b-0dbb6ddbb1ae
3
SemanticChunker@1.0.0
590d9ec5187f49ebce3bae9d7e79db9638cc7f6b1dd722eb934e1592ba41598e
[Currying a function > Uncurrying a function] ## Uncurrying a function _What about the opposite? How can we uncurry a function?_ We will still need to know the arity of the function, but this time, we will use `Array.prototype.reduce()` to call each subsequent curry level of the function. If the number of arguments i...
unknown
unknown
[Currying a function > Uncurrying a function] ## Uncurrying a function _What about the opposite? How can we uncurry a function?_ We will still need to know the arity of the function, but this time, we will use `Array.prototype.reduce()` to call each subsequent curry level of the function. If the number of arguments i...
[Currying a function > Uncurrying a function] ## Uncurrying a function _What about the opposite? How can we uncurry a function?_ We will still need to know the arity of the function, but this time, we will use `Array.prototype.reduce()` to call each subsequent curry level of the function. If the number of arguments i...
code_snippets
b2deee93-7317-40ca-a5fc-c350e7bccea5
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/currying.md
unknown
fe91081a-f9ec-473f-9a9b-0dbb6ddbb1ae
0
SemanticChunker@1.0.0
ff5bce4843c098088107c711378de92f7d63b0122a661827094b17e66a9e0327
--- title: Understanding JavaScript currying shortTitle: Currying language: javascript tags: [function,recursion] cover: tulips-and-reeds excerpt: Currying is a process that transforms a function that takes multiple arguments into a series of functions that each take a single argument. listed: true dateModified: 2023-1...
unknown
unknown
--- title: Understanding JavaScript currying shortTitle: Currying language: javascript tags: [function,recursion] cover: tulips-and-reeds excerpt: Currying is a process that transforms a function that takes multiple arguments into a series of functions that each take a single argument. listed: true dateModified: 2023-1...
--- title: Understanding JavaScript currying shortTitle: Currying language: javascript tags: [function,recursion] cover: tulips-and-reeds excerpt: Currying is a process that transforms a function that takes multiple arguments into a series of functions that each take a single argument. listed: true dateModified: 2023-1...
code_snippets
0d6c3ad8-0d74-437a-b512-45390cff6099
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-comparison.md
unknown
f67ebef9-896c-49d6-9d1e-5e54119430a0
0
SemanticChunker@1.0.0
90bca063341720626e6c10cd30905e067af06c7a3195fc08d21f9eb1ea65ad12
--- title: How do I compare two dates in JavaScript? shortTitle: Date comparison language: javascript tags: [date,comparison] cover: pineapple-at-work excerpt: Learn how you can compare two dates in JavaScript, determining which one comes before or after the other. listed: true dateModified: 2024-01-06 --- Comparing `...
unknown
unknown
--- title: How do I compare two dates in JavaScript? shortTitle: Date comparison language: javascript tags: [date,comparison] cover: pineapple-at-work excerpt: Learn how you can compare two dates in JavaScript, determining which one comes before or after the other. listed: true dateModified: 2024-01-06 --- Comparing `...
--- title: How do I compare two dates in JavaScript? shortTitle: Date comparison language: javascript tags: [date,comparison] cover: pineapple-at-work excerpt: Learn how you can compare two dates in JavaScript, determining which one comes before or after the other. listed: true dateModified: 2024-01-06 --- Comparing `...
code_snippets
7c90b501-322b-4463-b5ce-08fa8d3e1c1b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-comparison.md
unknown
f67ebef9-896c-49d6-9d1e-5e54119430a0
2
SemanticChunker@1.0.0
0e89063f4f357abe8acbfce741368ba06ef77e6eee5b8e3380d948cdac239848
[Date equality comparison > Date is before another date] ## Date is before another date As mentioned previously, `Date` objects act like numbers. This means that you can use the less than operator (`<`) to check if a date comes before another date. ```js const isBeforeDate = (dateA, dateB) => dateA < dateB; isBefor...
unknown
unknown
[Date equality comparison > Date is before another date] ## Date is before another date As mentioned previously, `Date` objects act like numbers. This means that you can use the less than operator (`<`) to check if a date comes before another date. ```js const isBeforeDate = (dateA, dateB) => dateA < dateB; isBefor...
[Date equality comparison > Date is before another date] ## Date is before another date As mentioned previously, `Date` objects act like numbers. This means that you can use the less than operator (`<`) to check if a date comes before another date. ```js const isBeforeDate = (dateA, dateB) => dateA < dateB; isBefor...
code_snippets
9cedc6a7-a4e7-448c-80fe-0256ce79f7fb
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-comparison.md
unknown
f67ebef9-896c-49d6-9d1e-5e54119430a0
1
SemanticChunker@1.0.0
b39f15539803734565a0f731528fb28bba02b6d9fb98ee500932755e74efc450
[Date equality comparison] ## Date equality comparison Comparing two dates using the [equality operators (`==` or `===`)](/js/s/equality) is ineffective, as it compares the objects **by reference**. Luckily, `Date.prototype.toISOString()` returns a string representation of the date in a **standardized format**, which...
unknown
unknown
[Date equality comparison] ## Date equality comparison Comparing two dates using the [equality operators (`==` or `===`)](/js/s/equality) is ineffective, as it compares the objects **by reference**. Luckily, `Date.prototype.toISOString()` returns a string representation of the date in a **standardized format**, which...
[Date equality comparison] ## Date equality comparison Comparing two dates using the [equality operators (`==` or `===`)](/js/s/equality) is ineffective, as it compares the objects **by reference**. Luckily, `Date.prototype.toISOString()` returns a string representation of the date in a **standardized format**, which...
code_snippets
a5831084-7722-4644-abf4-1d9f7695714c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-comparison.md
unknown
f67ebef9-896c-49d6-9d1e-5e54119430a0
3
SemanticChunker@1.0.0
cd81673b9408a2ffde7d8187bc4ec747c4d0cd27b0336cc4f9377d651066bbd3
[Date equality comparison > Date is after another date] ## Date is after another date Similarly, you can use the greater than operator (`>`) to check if a date comes after another date. ```js const isAfterDate = (dateA, dateB) => dateA > dateB; isAfterDate(new Date('2020-10-21'), new Date('2020-10-20')); // true ``...
unknown
unknown
[Date equality comparison > Date is after another date] ## Date is after another date Similarly, you can use the greater than operator (`>`) to check if a date comes after another date. ```js const isAfterDate = (dateA, dateB) => dateA > dateB; isAfterDate(new Date('2020-10-21'), new Date('2020-10-20')); // true ``...
[Date equality comparison > Date is after another date] ## Date is after another date Similarly, you can use the greater than operator (`>`) to check if a date comes after another date. ```js const isAfterDate = (dateA, dateB) => dateA > dateB; isAfterDate(new Date('2020-10-21'), new Date('2020-10-20')); // true ``...
code_snippets
d0dc2f80-c157-4491-bef9-d32cec4ee91a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-comparison.md
unknown
f67ebef9-896c-49d6-9d1e-5e54119430a0
4
SemanticChunker@1.0.0
9d1359da0918fea19c99b827fb11955d736ce877546521c91d07fd1cb9f56d0e
[Date equality comparison > Date is between two dates] ## Date is between two dates Combining the previous two snippets, you can check if a date is between two other dates. ```js const isBetweenDates = (dateStart, dateEnd, date) => date > dateStart && date < dateEnd; isBetweenDates( new Date('2020-10-20'), new D...
unknown
unknown
[Date equality comparison > Date is between two dates] ## Date is between two dates Combining the previous two snippets, you can check if a date is between two other dates. ```js const isBetweenDates = (dateStart, dateEnd, date) => date > dateStart && date < dateEnd; isBetweenDates( new Date('2020-10-20'), new D...
[Date equality comparison > Date is between two dates] ## Date is between two dates Combining the previous two snippets, you can check if a date is between two other dates. ```js const isBetweenDates = (dateStart, dateEnd, date) => date > dateStart && date < dateEnd; isBetweenDates( new Date('2020-10-20'), new D...
code_snippets
0095b455-9bbc-4b4e-9eab-67ebd5eb92c6
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-difference.md
unknown
68a0d518-9313-4691-b32d-95aae0a36dec
1
SemanticChunker@1.0.0
c62db5a5903fe1b5eec16dd745c3c1eeab4860bc8e36fb922f07a178468f9c79
[Date difference in seconds] ## Date difference in seconds Calculating the date difference in seconds is as simple as subtracting the two `Date` objects and dividing by the number of milliseconds in a second (`1000`). ```js const dateDifferenceInSeconds = (dateInitial, dateFinal) => (dateFinal - dateInitial) / 1_00...
unknown
unknown
[Date difference in seconds] ## Date difference in seconds Calculating the date difference in seconds is as simple as subtracting the two `Date` objects and dividing by the number of milliseconds in a second (`1000`). ```js const dateDifferenceInSeconds = (dateInitial, dateFinal) => (dateFinal - dateInitial) / 1_00...
[Date difference in seconds] ## Date difference in seconds Calculating the date difference in seconds is as simple as subtracting the two `Date` objects and dividing by the number of milliseconds in a second (`1000`). ```js const dateDifferenceInSeconds = (dateInitial, dateFinal) => (dateFinal - dateInitial) / 1_00...
code_snippets
11be3edd-53c8-43ea-ab70-d828a13e5578
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-difference.md
unknown
68a0d518-9313-4691-b32d-95aae0a36dec
2
SemanticChunker@1.0.0
25385010232f68879eb9449584d335cfefbd377e94633f4f2f4dad37ef217287
[Date difference in seconds > Date difference in minutes] ## Date difference in minutes Similarly, to calculate the date difference in minutes, we only need to change the divisor to the number of milliseconds in a minute (`1000 * 60`). ```js const dateDifferenceInMinutes = (dateInitial, dateFinal) => (dateFinal - d...
unknown
unknown
[Date difference in seconds > Date difference in minutes] ## Date difference in minutes Similarly, to calculate the date difference in minutes, we only need to change the divisor to the number of milliseconds in a minute (`1000 * 60`). ```js const dateDifferenceInMinutes = (dateInitial, dateFinal) => (dateFinal - d...
[Date difference in seconds > Date difference in minutes] ## Date difference in minutes Similarly, to calculate the date difference in minutes, we only need to change the divisor to the number of milliseconds in a minute (`1000 * 60`). ```js const dateDifferenceInMinutes = (dateInitial, dateFinal) => (dateFinal - d...
code_snippets
1b63ac3a-e429-4ad3-a3c2-d0b16afe0f3b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-difference.md
unknown
68a0d518-9313-4691-b32d-95aae0a36dec
7
SemanticChunker@1.0.0
9be710117464ccd4a86b51ed9aeea150a3ae955b67ef8ee7286b3470dc028388
[Date difference in seconds > Date difference in months] ## Date difference in months Months and years are easier to calculate with other `Date` methods, instead of subtraction. In such cases, we prefer to use `Date.prototype.getFullYear()` and `Date.prototype.getMonth()` to calculate the difference between the two d...
unknown
unknown
[Date difference in seconds > Date difference in months] ## Date difference in months Months and years are easier to calculate with other `Date` methods, instead of subtraction. In such cases, we prefer to use `Date.prototype.getFullYear()` and `Date.prototype.getMonth()` to calculate the difference between the two d...
[Date difference in seconds > Date difference in months] ## Date difference in months Months and years are easier to calculate with other `Date` methods, instead of subtraction. In such cases, we prefer to use `Date.prototype.getFullYear()` and `Date.prototype.getMonth()` to calculate the difference between the two d...
code_snippets
2de15969-e680-4470-aa1e-d03c366ace7b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-difference.md
unknown
68a0d518-9313-4691-b32d-95aae0a36dec
4
SemanticChunker@1.0.0
94207e4f5cdcc0c99a3efd050bb565a7ee589753fee32ba91d791898d5008218
[Date difference in seconds > Date difference in days] ## Date difference in days Subtraction can take us further still, calculating the date difference in days. Without taking timezones into account, we can simply divide the difference in milliseconds by the number of milliseconds in a day (`1000 * 60 * 60 * 24`). ...
unknown
unknown
[Date difference in seconds > Date difference in days] ## Date difference in days Subtraction can take us further still, calculating the date difference in days. Without taking timezones into account, we can simply divide the difference in milliseconds by the number of milliseconds in a day (`1000 * 60 * 60 * 24`). ...
[Date difference in seconds > Date difference in days] ## Date difference in days Subtraction can take us further still, calculating the date difference in days. Without taking timezones into account, we can simply divide the difference in milliseconds by the number of milliseconds in a day (`1000 * 60 * 60 * 24`). ...
code_snippets
3c9b3fd9-9212-42cc-979f-5aad0e966242
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-difference.md
unknown
68a0d518-9313-4691-b32d-95aae0a36dec
5
SemanticChunker@1.0.0
b7c26a1c7e2dc32c1251f68741d9b202c6d4735166eae0b0ea5c9a45b6923532
[Date difference in days > Date difference in weekdays] ### Date difference in weekdays Calculating the date difference in weekdays is a bit more involved. We first need a way to determine if a [given date is a weekday](/js/s/date-is-weekday-or-weekend). Then, we need to create an array of dates between the two dates...
unknown
unknown
[Date difference in days > Date difference in weekdays] ### Date difference in weekdays Calculating the date difference in weekdays is a bit more involved. We first need a way to determine if a [given date is a weekday](/js/s/date-is-weekday-or-weekend). Then, we need to create an array of dates between the two dates...
[Date difference in days > Date difference in weekdays] ### Date difference in weekdays Calculating the date difference in weekdays is a bit more involved. We first need a way to determine if a [given date is a weekday](/js/s/date-is-weekday-or-weekend). Then, we need to create an array of dates between the two dates...
code_snippets
9a5ec46b-e644-46b1-9b62-1f340e02e542
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-difference.md
unknown
68a0d518-9313-4691-b32d-95aae0a36dec
3
SemanticChunker@1.0.0
5481cb0c6211002161b2e8c5081cc3cdb02e8c0fb015b0980db19ce4535270f8
[Date difference in seconds > Date difference in hours] ## Date difference in hours To calculate the date difference in hours, we do the same thing, but with the number of milliseconds in an hour (`1000 * 60 * 60`). ```js const dateDifferenceInHours = (dateInitial, dateFinal) => (dateFinal - dateInitial) / 3_600_00...
unknown
unknown
[Date difference in seconds > Date difference in hours] ## Date difference in hours To calculate the date difference in hours, we do the same thing, but with the number of milliseconds in an hour (`1000 * 60 * 60`). ```js const dateDifferenceInHours = (dateInitial, dateFinal) => (dateFinal - dateInitial) / 3_600_00...
[Date difference in seconds > Date difference in hours] ## Date difference in hours To calculate the date difference in hours, we do the same thing, but with the number of milliseconds in an hour (`1000 * 60 * 60`). ```js const dateDifferenceInHours = (dateInitial, dateFinal) => (dateFinal - dateInitial) / 3_600_00...
code_snippets
b735e3cc-aa11-46ed-b68c-c6caf3ba5f11
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-difference.md
unknown
68a0d518-9313-4691-b32d-95aae0a36dec
0
SemanticChunker@1.0.0
eca8b3227d6d507714f1ab797e16c9152e11a796c9f7256357cb5086cc02f32a
--- title: How to calculate date difference in JavaScript shortTitle: Date difference language: javascript tags: [date] cover: laptop-journey excerpt: Learn how to calculate date difference in seconds, minutes, hours, days etc. in vanilla JavaScript. listed: true dateModified: 2024-01-06 --- Working with dates is hard...
unknown
unknown
--- title: How to calculate date difference in JavaScript shortTitle: Date difference language: javascript tags: [date] cover: laptop-journey excerpt: Learn how to calculate date difference in seconds, minutes, hours, days etc. in vanilla JavaScript. listed: true dateModified: 2024-01-06 --- Working with dates is hard...
--- title: How to calculate date difference in JavaScript shortTitle: Date difference language: javascript tags: [date] cover: laptop-journey excerpt: Learn how to calculate date difference in seconds, minutes, hours, days etc. in vanilla JavaScript. listed: true dateModified: 2024-01-06 --- Working with dates is hard...
code_snippets
bb450fff-2fc5-404d-89bd-1f94552cc3d5
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-difference.md
unknown
68a0d518-9313-4691-b32d-95aae0a36dec
8
SemanticChunker@1.0.0
25d58974dc3a0c39486661531d9db78a5c89e520a68649323992b4d11dfa3151
[Date difference in seconds > Date difference in years] ## Date difference in years Calculating the date difference in years is similar to the previous example, but we only need to divide the difference in months by `12`. ```js const dateDifferenceInYears = (dateInitial, dateFinal) => dateDifferenceInMonths(dateIni...
unknown
unknown
[Date difference in seconds > Date difference in years] ## Date difference in years Calculating the date difference in years is similar to the previous example, but we only need to divide the difference in months by `12`. ```js const dateDifferenceInYears = (dateInitial, dateFinal) => dateDifferenceInMonths(dateIni...
[Date difference in seconds > Date difference in years] ## Date difference in years Calculating the date difference in years is similar to the previous example, but we only need to divide the difference in months by `12`. ```js const dateDifferenceInYears = (dateInitial, dateFinal) => dateDifferenceInMonths(dateIni...
code_snippets
dd0eb79a-250d-4221-817b-839aee574805
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/date-difference.md
unknown
68a0d518-9313-4691-b32d-95aae0a36dec
6
SemanticChunker@1.0.0
ffb3e4b94ce58832212585e090815b94995fa67b637a4f5d7cf17fb062b1f6fb
[Date difference in seconds > Date difference in weeks] ## Date difference in weeks Calculating the date difference in weeks is still possible with simple date subtraction. We need only divide the difference in milliseconds by the number of milliseconds in a week (`1000 * 60 * 60 * 24 * 7`). ```js const dateDifferen...
unknown
unknown
[Date difference in seconds > Date difference in weeks] ## Date difference in weeks Calculating the date difference in weeks is still possible with simple date subtraction. We need only divide the difference in milliseconds by the number of milliseconds in a week (`1000 * 60 * 60 * 24 * 7`). ```js const dateDifferen...
[Date difference in seconds > Date difference in weeks] ## Date difference in weeks Calculating the date difference in weeks is still possible with simple date subtraction. We need only divide the difference in milliseconds by the number of milliseconds in a week (`1000 * 60 * 60 * 24 * 7`). ```js const dateDifferen...
code_snippets
55a9d182-82f9-4e63-89ac-52847046a2fc
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-linked-list.md
unknown
e450f96b-7f04-4600-8f9b-79b48436ff5e
0
SemanticChunker@1.0.0
77256e098a00881b713ec519b2fbdcfbd4925dd996c8f5b1722b7551883c573e
--- title: JavaScript Data Structures - Linked List shortTitle: Linked List language: javascript tags: [class] cover: purple-flower-macro-3 excerpt: A linked list is a linear data structure where each element points to the next. listed: true dateModified: 2021-08-08 ---
unknown
unknown
--- title: JavaScript Data Structures - Linked List shortTitle: Linked List language: javascript tags: [class] cover: purple-flower-macro-3 excerpt: A linked list is a linear data structure where each element points to the next. listed: true dateModified: 2021-08-08 ---
--- title: JavaScript Data Structures - Linked List shortTitle: Linked List language: javascript tags: [class] cover: purple-flower-macro-3 excerpt: A linked list is a linear data structure where each element points to the next. listed: true dateModified: 2021-08-08 ---
code_snippets
74249352-b985-4d0a-9230-f3cc4be26f3d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-linked-list.md
unknown
e450f96b-7f04-4600-8f9b-79b48436ff5e
1
SemanticChunker@1.0.0
e8cc16d2b585db0202243b65df1b390c92b23de492a20b5ad6b87fbf9de4fdf8
[Definition] ## Definition A linked list is a linear data structure that represents a collection of elements, where each element points to the next one. The first element in the linked list is the head and the last element is the tail. ![JavaScript Linked List visualization](./illustrations/ds-linked-list.svg) Each...
unknown
unknown
[Definition] ## Definition A linked list is a linear data structure that represents a collection of elements, where each element points to the next one. The first element in the linked list is the head and the last element is the tail. ![JavaScript Linked List visualization](./illustrations/ds-linked-list.svg) Each...
[Definition] ## Definition A linked list is a linear data structure that represents a collection of elements, where each element points to the next one. The first element in the linked list is the head and the last element is the tail. ![JavaScript Linked List visualization](./illustrations/ds-linked-list.svg) Each...
code_snippets
74ec59e1-ca2c-4edd-a426-1f70cb280f15
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-linked-list.md
unknown
e450f96b-7f04-4600-8f9b-79b48436ff5e
3
SemanticChunker@1.0.0
ac09e659186206c096d38850ee3931a367fb55e529d9d6f6852dcdae972b3c70
[Definition > Implementation] - Create a `class` with a `constructor` that initializes an empty array, `nodes`, for each instance. - Define a `size` getter, that returns that uses `Array.prototype.length` to return the number of elements in the `nodes` array. - Define a `head` getter, that returns the first element of...
unknown
unknown
[Definition > Implementation] - Create a `class` with a `constructor` that initializes an empty array, `nodes`, for each instance. - Define a `size` getter, that returns that uses `Array.prototype.length` to return the number of elements in the `nodes` array. - Define a `head` getter, that returns the first element of...
[Definition > Implementation] - Create a `class` with a `constructor` that initializes an empty array, `nodes`, for each instance. - Define a `size` getter, that returns that uses `Array.prototype.length` to return the number of elements in the `nodes` array. - Define a `head` getter, that returns the first element of...
code_snippets
bd14dfbf-fa82-4246-8a76-120d30c0efcd
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-linked-list.md
unknown
e450f96b-7f04-4600-8f9b-79b48436ff5e
2
SemanticChunker@1.0.0
a39b29c7ba4d6deb8abf89cd5a4250b4be1d66a65aa0d36ba823ad808c073b08
[Definition > Implementation] ## Implementation ```js class LinkedList { constructor() { this.nodes = []; } get size() { return this.nodes.length; } get head() { return this.size ? this.nodes[0] : null; } get tail() { return this.size ? this.nodes[this.size - 1] : null; } insertAt(index, value) { co...
unknown
unknown
[Definition > Implementation] ## Implementation ```js class LinkedList { constructor() { this.nodes = []; } get size() { return this.nodes.length; } get head() { return this.size ? this.nodes[0] : null; } get tail() { return this.size ? this.nodes[this.size - 1] : null; } insertAt(index, value) { co...
[Definition > Implementation] ## Implementation ```js class LinkedList { constructor() { this.nodes = []; } get size() { return this.nodes.length; } get head() { return this.size ? this.nodes[0] : null; } get tail() { return this.size ? this.nodes[this.size - 1] : null; } insertAt(index, value) { co...
code_snippets
d81a15dc-6898-449b-bcd9-a750a76617ee
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-linked-list.md
unknown
e450f96b-7f04-4600-8f9b-79b48436ff5e
4
SemanticChunker@1.0.0
a6b77c5d981df04abc806ebd14824e06cfd18308c777f978513c567f9b3e5b7b
[Definition > Implementation] ```js const list = new LinkedList(); list.insertFirst(1); list.insertFirst(2); list.insertFirst(3); list.insertLast(4); list.insertAt(3, 5); list.size; // 5 list.head.value; // 3 list.head.next.value; // 2 list.tail.value; // 4 [...list.map(e => e.value)]; // [3, 2, 1, 5, 4] list.remov...
unknown
unknown
[Definition > Implementation] ```js const list = new LinkedList(); list.insertFirst(1); list.insertFirst(2); list.insertFirst(3); list.insertLast(4); list.insertAt(3, 5); list.size; // 5 list.head.value; // 3 list.head.next.value; // 2 list.tail.value; // 4 [...list.map(e => e.value)]; // [3, 2, 1, 5, 4] list.remov...
[Definition > Implementation] ```js const list = new LinkedList(); list.insertFirst(1); list.insertFirst(2); list.insertFirst(3); list.insertLast(4); list.insertAt(3, 5); list.size; // 5 list.head.value; // 3 list.head.next.value; // 2 list.tail.value; // 4 [...list.map(e => e.value)]; // [3, 2, 1, 5, 4] list.remov...
code_snippets
1395e6ea-5f0d-4b04-8489-bb797f27729b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-graph.md
unknown
8ea781a8-ae0a-4ab0-9644-15e46d257737
0
SemanticChunker@1.0.0
2d85064aed49cb56c99f4596cf96fb0b324b99bc902423d909a80e1886c07258
--- title: JavaScript Data Structures - Graph shortTitle: Graph language: javascript tags: [class] cover: purple-flower-macro-1 excerpt: A graph is a data structure consisting of a set of vertices connected by a set of edges. listed: true dateModified: 2021-08-17 ---
unknown
unknown
--- title: JavaScript Data Structures - Graph shortTitle: Graph language: javascript tags: [class] cover: purple-flower-macro-1 excerpt: A graph is a data structure consisting of a set of vertices connected by a set of edges. listed: true dateModified: 2021-08-17 ---
--- title: JavaScript Data Structures - Graph shortTitle: Graph language: javascript tags: [class] cover: purple-flower-macro-1 excerpt: A graph is a data structure consisting of a set of vertices connected by a set of edges. listed: true dateModified: 2021-08-17 ---
code_snippets
19eb2447-6bbb-499a-a7f2-9130ba94eb81
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-graph.md
unknown
8ea781a8-ae0a-4ab0-9644-15e46d257737
1
SemanticChunker@1.0.0
a9b39cc099fa9892097aa38d70d425374d1fa26b2743d98f062f50b2a2def937
[Definition] ## Definition A graph is a data structure consisting of a set of nodes or vertices and a set of edges that represent connections between those nodes. Graphs can be directed or undirected, while their edges can be assigned numeric weights. ![JavaScript Graph visualization](./illustrations/ds-graph.svg) ...
unknown
unknown
[Definition] ## Definition A graph is a data structure consisting of a set of nodes or vertices and a set of edges that represent connections between those nodes. Graphs can be directed or undirected, while their edges can be assigned numeric weights. ![JavaScript Graph visualization](./illustrations/ds-graph.svg) ...
[Definition] ## Definition A graph is a data structure consisting of a set of nodes or vertices and a set of edges that represent connections between those nodes. Graphs can be directed or undirected, while their edges can be assigned numeric weights. ![JavaScript Graph visualization](./illustrations/ds-graph.svg) ...
code_snippets
4e575780-0cf3-443c-8bbd-33dab6eb8245
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-graph.md
unknown
8ea781a8-ae0a-4ab0-9644-15e46d257737
3
SemanticChunker@1.0.0
d9b81808cea46ddeee3512a349ea5f1d91c68915ce2ca9b53872ef7d46e7f7bd
[Definition > Implementation] - Define an `addNode()` method, which uses `Array.prototype.push()` to add a new node in the `nodes` array. - Define an `addEdge()` method, which uses `Map.prototype.set()` to add a new edge to the `edges` Map, using `JSON.stringify()` to produce a unique key. - Define a `removeNode()` me...
unknown
unknown
[Definition > Implementation] - Define an `addNode()` method, which uses `Array.prototype.push()` to add a new node in the `nodes` array. - Define an `addEdge()` method, which uses `Map.prototype.set()` to add a new edge to the `edges` Map, using `JSON.stringify()` to produce a unique key. - Define a `removeNode()` me...
[Definition > Implementation] - Define an `addNode()` method, which uses `Array.prototype.push()` to add a new node in the `nodes` array. - Define an `addEdge()` method, which uses `Map.prototype.set()` to add a new edge to the `edges` Map, using `JSON.stringify()` to produce a unique key. - Define a `removeNode()` me...
code_snippets
c3d1a22f-0b79-43b8-a24f-56b2196291ef
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-graph.md
unknown
8ea781a8-ae0a-4ab0-9644-15e46d257737
2
SemanticChunker@1.0.0
4368e3c1c55cb50e7765eea38946dc4260b2b664414cd22c1fa04c66705ba032
[Definition > Implementation] ## Implementation ```js class Graph { constructor(directed = true) { this.directed = directed; this.nodes = []; this.edges = new Map(); } addNode(key, value = key) { this.nodes.push({ key, value }); } addEdge(a, b, weight) { this.edges.set(JSON.stringify([a, b]), { a, b, weig...
unknown
unknown
[Definition > Implementation] ## Implementation ```js class Graph { constructor(directed = true) { this.directed = directed; this.nodes = []; this.edges = new Map(); } addNode(key, value = key) { this.nodes.push({ key, value }); } addEdge(a, b, weight) { this.edges.set(JSON.stringify([a, b]), { a, b, weig...
[Definition > Implementation] ## Implementation ```js class Graph { constructor(directed = true) { this.directed = directed; this.nodes = []; this.edges = new Map(); } addNode(key, value = key) { this.nodes.push({ key, value }); } addEdge(a, b, weight) { this.edges.set(JSON.stringify([a, b]), { a, b, weig...
code_snippets
f940fea3-3636-48c2-a31e-0de8e9ec63d0
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-graph.md
unknown
8ea781a8-ae0a-4ab0-9644-15e46d257737
4
SemanticChunker@1.0.0
b718b905756fd2e837d848219b52083f86e2691bdeffdd4b082af46cb27e7765
[Definition > Implementation] ```js const g = new Graph(); g.addNode('a'); g.addNode('b'); g.addNode('c'); g.addNode('d'); g.addEdge('a', 'c'); g.addEdge('b', 'c'); g.addEdge('c', 'b'); g.addEdge('d', 'a'); g.nodes.map(x => x.value); // ['a', 'b', 'c', 'd'] [...g.edges.values()].map(({ a, b }) => `${a} => ${b}`); /...
unknown
unknown
[Definition > Implementation] ```js const g = new Graph(); g.addNode('a'); g.addNode('b'); g.addNode('c'); g.addNode('d'); g.addEdge('a', 'c'); g.addEdge('b', 'c'); g.addEdge('c', 'b'); g.addEdge('d', 'a'); g.nodes.map(x => x.value); // ['a', 'b', 'c', 'd'] [...g.edges.values()].map(({ a, b }) => `${a} => ${b}`); /...
[Definition > Implementation] ```js const g = new Graph(); g.addNode('a'); g.addNode('b'); g.addNode('c'); g.addNode('d'); g.addEdge('a', 'c'); g.addEdge('b', 'c'); g.addEdge('c', 'b'); g.addEdge('d', 'a'); g.nodes.map(x => x.value); // ['a', 'b', 'c', 'd'] [...g.edges.values()].map(({ a, b }) => `${a} => ${b}`); /...
code_snippets
0d3b8d85-6722-4cb0-9812-1daddf59b64e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-doubly-linked-list.md
unknown
1b901c12-e1c5-49d5-bde9-169c907b5721
3
SemanticChunker@1.0.0
165b26553c949eda41ac236b0ec550e7f008351eebe908f4894213703de2e528
[Definition > Implementation] - Create a `class` with a `constructor` that initializes an empty array, `nodes`, for each instance. - Define a `size` getter, that returns that uses `Array.prototype.length` to return the number of elements in the `nodes` array. - Define a `head` getter, that returns the first element of...
unknown
unknown
[Definition > Implementation] - Create a `class` with a `constructor` that initializes an empty array, `nodes`, for each instance. - Define a `size` getter, that returns that uses `Array.prototype.length` to return the number of elements in the `nodes` array. - Define a `head` getter, that returns the first element of...
[Definition > Implementation] - Create a `class` with a `constructor` that initializes an empty array, `nodes`, for each instance. - Define a `size` getter, that returns that uses `Array.prototype.length` to return the number of elements in the `nodes` array. - Define a `head` getter, that returns the first element of...
code_snippets
6147fb73-0f11-43ef-bf48-e57ef8e90bf4
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-doubly-linked-list.md
unknown
1b901c12-e1c5-49d5-bde9-169c907b5721
2
SemanticChunker@1.0.0
e703daa5ef63cc5bbcd08aec71ec525c3805558708615e760b24f952999289e3
[Definition > Implementation] ## Implementation ```js class DoublyLinkedList { constructor() { this.nodes = []; } get size() { return this.nodes.length; } get head() { return this.size ? this.nodes[0] : null; } get tail() { return this.size ? this.nodes[this.size - 1] : null; } insertAt(index, value)...
unknown
unknown
[Definition > Implementation] ## Implementation ```js class DoublyLinkedList { constructor() { this.nodes = []; } get size() { return this.nodes.length; } get head() { return this.size ? this.nodes[0] : null; } get tail() { return this.size ? this.nodes[this.size - 1] : null; } insertAt(index, value)...
[Definition > Implementation] ## Implementation ```js class DoublyLinkedList { constructor() { this.nodes = []; } get size() { return this.nodes.length; } get head() { return this.size ? this.nodes[0] : null; } get tail() { return this.size ? this.nodes[this.size - 1] : null; } insertAt(index, value)...
code_snippets
6aa310e4-1d51-4b87-b01e-9ad718b3a206
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/data-structures-doubly-linked-list.md
unknown
1b901c12-e1c5-49d5-bde9-169c907b5721
0
SemanticChunker@1.0.0
3aef855f3884655638dd2ac54ff84eccf25b5f512f21ce07e28bda9856ad8800
--- title: JavaScript Data Structures - Doubly Linked List shortTitle: Doubly Linked List language: javascript tags: [class] cover: purple-flower-macro-4 excerpt: A doubly linked list is a linear data structure where each element points both to the next and the previous one. listed: true dateModified: 2021-08-12 ---
unknown
unknown
--- title: JavaScript Data Structures - Doubly Linked List shortTitle: Doubly Linked List language: javascript tags: [class] cover: purple-flower-macro-4 excerpt: A doubly linked list is a linear data structure where each element points both to the next and the previous one. listed: true dateModified: 2021-08-12 ---
--- title: JavaScript Data Structures - Doubly Linked List shortTitle: Doubly Linked List language: javascript tags: [class] cover: purple-flower-macro-4 excerpt: A doubly linked list is a linear data structure where each element points both to the next and the previous one. listed: true dateModified: 2021-08-12 ---
code_snippets