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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
646ae625-d5ea-4cf1-9796-a6b479eaa158 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/percentile-of-matches.md | unknown | e0d647ae-afed-48e8-8054-2e3f750e618b | 0 | SemanticChunker@1.0.0 | 6dba6555280afac4b4c0a51f111ec068187a73f0dac11d501f31aae8a7dd978f | ---
title: Percentile of matches in a JavaScript array
shortTitle: Percentile of matches
language: javascript
tags: [math]
cover: collab-desk-2
excerpt: Calculate the percentage of numbers in the given array that are less or equal to the given value.
listed: true
dateModified: 2024-08-02
---
Given an array of numbers,... | unknown | unknown | ---
title: Percentile of matches in a JavaScript array
shortTitle: Percentile of matches
language: javascript
tags: [math]
cover: collab-desk-2
excerpt: Calculate the percentage of numbers in the given array that are less or equal to the given value.
listed: true
dateModified: 2024-08-02
---
Given an array of numbers,... | ---
title: Percentile of matches in a JavaScript array
shortTitle: Percentile of matches
language: javascript
tags: [math]
cover: collab-desk-2
excerpt: Calculate the percentage of numbers in the given array that are less or equal to the given value.
listed: true
dateModified: 2024-08-02
---
Given an array of numbers,... | code_snippets | ||
0da25609-ef53-4ef5-aa1a-1639305c6712 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pass-by-reference-or-pass-by-value.md | unknown | b3a9fb85-5f1e-4575-a613-194babdbc9cc | 0 | SemanticChunker@1.0.0 | 5d64fa5df8024730e619de857a2c0f3a8326b4b492cbcbc9ea4acdce93534cbd | ---
title: Is JavaScript pass-by-value or pass-by-reference?
shortTitle: Pass-by-value or pass-by-reference
language: javascript
tags: [function,object]
cover: balloons-field
excerpt: How JavaScript handles passing data is a source of confusion and bugs for many developers, especially when it comes to object types.
lis... | unknown | unknown | ---
title: Is JavaScript pass-by-value or pass-by-reference?
shortTitle: Pass-by-value or pass-by-reference
language: javascript
tags: [function,object]
cover: balloons-field
excerpt: How JavaScript handles passing data is a source of confusion and bugs for many developers, especially when it comes to object types.
lis... | ---
title: Is JavaScript pass-by-value or pass-by-reference?
shortTitle: Pass-by-value or pass-by-reference
language: javascript
tags: [function,object]
cover: balloons-field
excerpt: How JavaScript handles passing data is a source of confusion and bugs for many developers, especially when it comes to object types.
lis... | code_snippets | ||
c301404f-1b0c-44b4-abbd-c896ca22c5fb | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pass-by-reference-or-pass-by-value.md | unknown | b3a9fb85-5f1e-4575-a613-194babdbc9cc | 1 | SemanticChunker@1.0.0 | da24309cd86de52b4754344a2f80d3d3a7b02968678e5ecd67b71f255a2907ad | In this example, `myObj` is a plain JavaScript object, passed as an argument to `myFunc`. The `obj` argument inside `myFunc` is a reference to the same object, `myObj`. Any changes made to `obj` affect `myObj`, as they are the exact same object. This means that assigning the result (`obj`) of the function call to anoth... | unknown | unknown | In this example, `myObj` is a plain JavaScript object, passed as an argument to `myFunc`. The `obj` argument inside `myFunc` is a reference to the same object, `myObj`. Any changes made to `obj` affect `myObj`, as they are the exact same object. This means that assigning the result (`obj`) of the function call to anoth... | In this example, `myObj` is a plain JavaScript object, passed as an argument to `myFunc`. The `obj` argument inside `myFunc` is a reference to the same object, `myObj`. Any changes made to `obj` affect `myObj`, as they are the exact same object. This means that assigning the result (`obj`) of the function call to anoth... | code_snippets | ||
66f92f11-be34-43c8-b79f-efee1a76f0f7 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partially-apply-function.md | unknown | 7649536d-041f-469b-88e5-1f0749b38571 | 1 | SemanticChunker@1.0.0 | d4e63991096ad7856a183a165ef49d893bc280f89ae22ba2198e364278d56959 | [Prepend arguments to a function]
## Prepend arguments to a function
In order to partially apply a function by prepending arguments, you can use the spread operator (`...`) to prepend `partials` to the list of arguments of `fn`. Simply pass `partials` **before any other arguments** that are supplied.
```js
const par... | unknown | unknown | [Prepend arguments to a function]
## Prepend arguments to a function
In order to partially apply a function by prepending arguments, you can use the spread operator (`...`) to prepend `partials` to the list of arguments of `fn`. Simply pass `partials` **before any other arguments** that are supplied.
```js
const par... | [Prepend arguments to a function]
## Prepend arguments to a function
In order to partially apply a function by prepending arguments, you can use the spread operator (`...`) to prepend `partials` to the list of arguments of `fn`. Simply pass `partials` **before any other arguments** that are supplied.
```js
const par... | code_snippets | ||
82de24eb-22c9-4888-b6b2-d2d3cb5866df | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partially-apply-function.md | unknown | 7649536d-041f-469b-88e5-1f0749b38571 | 0 | SemanticChunker@1.0.0 | abe4d9d0831357c55fdca5651ecf115c577917337d1f94d9c3aaa6fa30c79735 | ---
title: How can I partially apply a function in JavaScript?
shortTitle: Partial function application
language: javascript
tags: [function]
cover: rocky-beach
excerpt: Learn how to leverage partial application to improve the reusability of your JavaScript functions.
listed: true
dateModified: 2024-01-31
journeyId: js... | unknown | unknown | ---
title: How can I partially apply a function in JavaScript?
shortTitle: Partial function application
language: javascript
tags: [function]
cover: rocky-beach
excerpt: Learn how to leverage partial application to improve the reusability of your JavaScript functions.
listed: true
dateModified: 2024-01-31
journeyId: js... | ---
title: How can I partially apply a function in JavaScript?
shortTitle: Partial function application
language: javascript
tags: [function]
cover: rocky-beach
excerpt: Learn how to leverage partial application to improve the reusability of your JavaScript functions.
listed: true
dateModified: 2024-01-31
journeyId: js... | code_snippets | ||
c8d2e47f-dc3f-475f-b8f1-1093770b0ce8 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partially-apply-function.md | unknown | 7649536d-041f-469b-88e5-1f0749b38571 | 2 | SemanticChunker@1.0.0 | d87452213c6afebb97cd44066e20ec2b3b77b2085e5743766c534013d4df9fb9 | [Prepend arguments to a function > Append arguments to a function]
## Append arguments to a function
Similarly, you can partially apply a function by appending arguments using the spread operator (`...`). You need only pass them to `fn` **after any other arguments** that are supplied.
```js
const partialRight = (fn,... | unknown | unknown | [Prepend arguments to a function > Append arguments to a function]
## Append arguments to a function
Similarly, you can partially apply a function by appending arguments using the spread operator (`...`). You need only pass them to `fn` **after any other arguments** that are supplied.
```js
const partialRight = (fn,... | [Prepend arguments to a function > Append arguments to a function]
## Append arguments to a function
Similarly, you can partially apply a function by appending arguments using the spread operator (`...`). You need only pass them to `fn` **after any other arguments** that are supplied.
```js
const partialRight = (fn,... | code_snippets | ||
d0810877-e038-48cf-a200-95018f771de1 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/passive-scroll-listener-performance.md | unknown | cbaec105-9606-4352-a65a-1a52fbdd6f3c | 0 | SemanticChunker@1.0.0 | 613291615460449e96eb6ea84c28f506ba4cc3683f0fc32db3f0af401c82d638 | ---
title: Improve JavaScript scroll listener performance
shortTitle: Improve scroll listener performance
language: javascript
tags: [browser,event]
cover: chill-surfing
excerpt: Scroll listeners can easily become a performance bottleneck for your web application. Here's how to fix that.
listed: true
dateModified: 2023... | unknown | unknown | ---
title: Improve JavaScript scroll listener performance
shortTitle: Improve scroll listener performance
language: javascript
tags: [browser,event]
cover: chill-surfing
excerpt: Scroll listeners can easily become a performance bottleneck for your web application. Here's how to fix that.
listed: true
dateModified: 2023... | ---
title: Improve JavaScript scroll listener performance
shortTitle: Improve scroll listener performance
language: javascript
tags: [browser,event]
cover: chill-surfing
excerpt: Scroll listeners can easily become a performance bottleneck for your web application. Here's how to fix that.
listed: true
dateModified: 2023... | code_snippets | ||
668b015b-fac9-4536-b2b1-5341c4575068 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partial-sum-array.md | unknown | 36a47f39-070d-4fb9-924d-db0044a94c82 | 0 | SemanticChunker@1.0.0 | 7593d2f43def66629c38ed9db770045687f96a89ad61a74714824fb5f0fd03b8 | ---
title: Create an array of partial sums in JavaScript
shortTitle: Partial sum array
language: javascript
tags: [array,math]
cover: people-on-beach
excerpt: Create an array of partial sums, using `Array.prototype.reduce()` and `Array.prototype.slice()`.
listed: true
dateModified: 2024-03-24
---
The **partial sum** o... | unknown | unknown | ---
title: Create an array of partial sums in JavaScript
shortTitle: Partial sum array
language: javascript
tags: [array,math]
cover: people-on-beach
excerpt: Create an array of partial sums, using `Array.prototype.reduce()` and `Array.prototype.slice()`.
listed: true
dateModified: 2024-03-24
---
The **partial sum** o... | ---
title: Create an array of partial sums in JavaScript
shortTitle: Partial sum array
language: javascript
tags: [array,math]
cover: people-on-beach
excerpt: Create an array of partial sums, using `Array.prototype.reduce()` and `Array.prototype.slice()`.
listed: true
dateModified: 2024-03-24
---
The **partial sum** o... | code_snippets | ||
08ae21bf-262e-4e76-85c4-6d4013041d15 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partial-search-matching.md | unknown | 0d79a970-f462-4e34-9c03-cea566a634de | 1 | SemanticChunker@1.0.0 | 437e331ca54b7eb946fa9b3a41df1286def049d80d8fb62c6c426ff5ce9ac6b9 | [Partial matching]
## Partial matching
Partial matching is a technique that allows you to search for **documents that contain a substring of the search term**. It's most often employed in search pages where the results are populated while you type. You may, for example, start typing _"JavaScript"_ and get results as ... | unknown | unknown | [Partial matching]
## Partial matching
Partial matching is a technique that allows you to search for **documents that contain a substring of the search term**. It's most often employed in search pages where the results are populated while you type. You may, for example, start typing _"JavaScript"_ and get results as ... | [Partial matching]
## Partial matching
Partial matching is a technique that allows you to search for **documents that contain a substring of the search term**. It's most often employed in search pages where the results are populated while you type. You may, for example, start typing _"JavaScript"_ and get results as ... | code_snippets | ||
2f66c0cb-8cae-4ed4-a787-d45bcde25736 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partial-search-matching.md | unknown | 0d79a970-f462-4e34-9c03-cea566a634de | 5 | SemanticChunker@1.0.0 | f82b80ebd8afe031eea18f7ea2fe9c0ca1784defd62ec328caae417f2dc41f13 | [Partial matching > Matching only when needed]
Given the results, I would say this is a pretty good solution, that follows the principles we've established so far, ranking documents by their relevance to the search term. | unknown | unknown | [Partial matching > Matching only when needed]
Given the results, I would say this is a pretty good solution, that follows the principles we've established so far, ranking documents by their relevance to the search term. | [Partial matching > Matching only when needed]
Given the results, I would say this is a pretty good solution, that follows the principles we've established so far, ranking documents by their relevance to the search term. | code_snippets | ||
481b8e99-1fd9-4f2f-be05-b8c0c6106dbc | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partial-search-matching.md | unknown | 0d79a970-f462-4e34-9c03-cea566a634de | 3 | SemanticChunker@1.0.0 | 3a2ba538d49e6235d83ae95bd6d9a3971a56b107fd5d870b6022b5823113166b | [Partial matching > Matching only when needed]
// Built on the previous article's code
addDocument('JavaScript is a web programming language.');
addDocument('Java is a general-purpose programming language');
search('java'); // Returns the second document [1]
search('javasc'); // Returns no documents, logs partial mat... | unknown | unknown | [Partial matching > Matching only when needed]
// Built on the previous article's code
addDocument('JavaScript is a web programming language.');
addDocument('Java is a general-purpose programming language');
search('java'); // Returns the second document [1]
search('javasc'); // Returns no documents, logs partial mat... | [Partial matching > Matching only when needed]
// Built on the previous article's code
addDocument('JavaScript is a web programming language.');
addDocument('Java is a general-purpose programming language');
search('java'); // Returns the second document [1]
search('javasc'); // Returns no documents, logs partial mat... | code_snippets | ||
5cc11fc0-39f7-4742-8f83-55b09f38e146 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partial-search-matching.md | unknown | 0d79a970-f462-4e34-9c03-cea566a634de | 4 | SemanticChunker@1.0.0 | ea6db76673005299c3dad81aab828ea9dae99ca4445ab02c4e5e01fac57772b0 | [Partial matching > Matching only when needed]
```
> [!NOTE]
>
> These **heuristics** seem to work well in my **limited experience**. Take them with a pinch of salt, as you may need to tweak them to find the best solution for your use case.
As you can see, this solution ensures that if a term is found in the inverte... | unknown | unknown | [Partial matching > Matching only when needed]
```
> [!NOTE]
>
> These **heuristics** seem to work well in my **limited experience**. Take them with a pinch of salt, as you may need to tweak them to find the best solution for your use case.
As you can see, this solution ensures that if a term is found in the inverte... | [Partial matching > Matching only when needed]
```
> [!NOTE]
>
> These **heuristics** seem to work well in my **limited experience**. Take them with a pinch of salt, as you may need to tweak them to find the best solution for your use case.
As you can see, this solution ensures that if a term is found in the inverte... | code_snippets | ||
d0164d40-344e-4ca4-8a58-90b8f3876020 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partial-search-matching.md | unknown | 0d79a970-f462-4e34-9c03-cea566a634de | 6 | SemanticChunker@1.0.0 | 4517e7538cd46a5658377843d368a9567df47f6257af49da01895368f2c8d3b7 | [Partial matching > Conclusion]
## Conclusion
TF-IDF, inverted indexes and now partial matching. This is a pretty good combination of techniques to implement a search engine. I'll let you in on a little secret: they're exactly what I've implemented for the search engine on this website and I'm pretty happy with the r... | unknown | unknown | [Partial matching > Conclusion]
## Conclusion
TF-IDF, inverted indexes and now partial matching. This is a pretty good combination of techniques to implement a search engine. I'll let you in on a little secret: they're exactly what I've implemented for the search engine on this website and I'm pretty happy with the r... | [Partial matching > Conclusion]
## Conclusion
TF-IDF, inverted indexes and now partial matching. This is a pretty good combination of techniques to implement a search engine. I'll let you in on a little secret: they're exactly what I've implemented for the search engine on this website and I'm pretty happy with the r... | code_snippets | ||
e29ecb3f-0da1-41b3-81b0-b63a546848fb | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partial-search-matching.md | unknown | 0d79a970-f462-4e34-9c03-cea566a634de | 2 | SemanticChunker@1.0.0 | 76d4927de5b98325cd3176814b1e87933d52aa91cb66786c54884d484a28e287 | [Partial matching > Matching only when needed]
## Matching only when needed
We'll have to add some **conditions** to check for partial matches. The first one of them is trivially simple: we need **only partially match the last term** in the search query. This matches how users naturally type, so it makes sense.
The ... | unknown | unknown | [Partial matching > Matching only when needed]
## Matching only when needed
We'll have to add some **conditions** to check for partial matches. The first one of them is trivially simple: we need **only partially match the last term** in the search query. This matches how users naturally type, so it makes sense.
The ... | [Partial matching > Matching only when needed]
## Matching only when needed
We'll have to add some **conditions** to check for partial matches. The first one of them is trivially simple: we need **only partially match the last term** in the search query. This matches how users naturally type, so it makes sense.
The ... | code_snippets | ||
ea9e6429-1e0d-40e9-b350-a6edd418438d | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/partial-search-matching.md | unknown | 0d79a970-f462-4e34-9c03-cea566a634de | 0 | SemanticChunker@1.0.0 | 54f87680ac6556d5646c9cd8b5abf909439a4c4666232ebd4a2e9efc89449c0b | ---
title: Implementing partial search matching in JavaScript
shortTitle: Partial search matching
language: javascript
tags: [algorithm,string,regexp]
cover: interior-9
excerpt: Building on top of the TF-IDF and inverted index implementation, we will implement partial search matching to make searching more robust.
list... | unknown | unknown | ---
title: Implementing partial search matching in JavaScript
shortTitle: Partial search matching
language: javascript
tags: [algorithm,string,regexp]
cover: interior-9
excerpt: Building on top of the TF-IDF and inverted index implementation, we will implement partial search matching to make searching more robust.
list... | ---
title: Implementing partial search matching in JavaScript
shortTitle: Partial search matching
language: javascript
tags: [algorithm,string,regexp]
cover: interior-9
excerpt: Building on top of the TF-IDF and inverted index implementation, we will implement partial search matching to make searching more robust.
list... | code_snippets | ||
2e1adc91-22f3-4921-af65-95eaf1ecaa15 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pluck-values-from-object-array.md | unknown | b0d4aec8-eb02-47b0-8f7a-6fcdc38ba3bd | 3 | SemanticChunker@1.0.0 | 2357fbb1fa5926555eea8cb02d5fffa477f168dce4ac7b2bede601e0bcab87c6 | [Pluck a single value for each object > Pluck any number of values for each object]
## Pluck any number of values for each object
Instead of having two separate functions for plucking a single value and multiple values, you can create a single function that accepts a **variable number of keys**. This way, you can plu... | unknown | unknown | [Pluck a single value for each object > Pluck any number of values for each object]
## Pluck any number of values for each object
Instead of having two separate functions for plucking a single value and multiple values, you can create a single function that accepts a **variable number of keys**. This way, you can plu... | [Pluck a single value for each object > Pluck any number of values for each object]
## Pluck any number of values for each object
Instead of having two separate functions for plucking a single value and multiple values, you can create a single function that accepts a **variable number of keys**. This way, you can plu... | code_snippets | ||
3472ed96-4dca-4082-9667-1a6c82b38157 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pluck-values-from-object-array.md | unknown | b0d4aec8-eb02-47b0-8f7a-6fcdc38ba3bd | 0 | SemanticChunker@1.0.0 | 8df335511531e3d2ee2d5160ad7968ec1a8bf486a56b5a90e983926a49cd7c7a | ---
title: Pluck values from an array of objects in JavaScript
shortTitle: Pluck values from object array
language: javascript
tags: [array,object]
cover: birds
excerpt: Learn how to extract values from an array of objects based on a specified key.
listed: true
dateModified: 2024-03-22
---
Ever wanted to **extract val... | unknown | unknown | ---
title: Pluck values from an array of objects in JavaScript
shortTitle: Pluck values from object array
language: javascript
tags: [array,object]
cover: birds
excerpt: Learn how to extract values from an array of objects based on a specified key.
listed: true
dateModified: 2024-03-22
---
Ever wanted to **extract val... | ---
title: Pluck values from an array of objects in JavaScript
shortTitle: Pluck values from object array
language: javascript
tags: [array,object]
cover: birds
excerpt: Learn how to extract values from an array of objects based on a specified key.
listed: true
dateModified: 2024-03-22
---
Ever wanted to **extract val... | code_snippets | ||
85e2feb3-5bc4-4468-a555-1dcba4c82325 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pluck-values-from-object-array.md | unknown | b0d4aec8-eb02-47b0-8f7a-6fcdc38ba3bd | 2 | SemanticChunker@1.0.0 | 416d0dac305c8a64c0cfcd812e9aedba2ca3bbe259630c68a44fa26a9ccded50 | [Pluck a single value for each object > Pluck multiple values for each object]
## Pluck multiple values for each object
If you want to extract **multiple values** for each object, you can use a nested `map()` to iterate over the keys. This results in each object being mapped to an array of values.
```js
const pluck ... | unknown | unknown | [Pluck a single value for each object > Pluck multiple values for each object]
## Pluck multiple values for each object
If you want to extract **multiple values** for each object, you can use a nested `map()` to iterate over the keys. This results in each object being mapped to an array of values.
```js
const pluck ... | [Pluck a single value for each object > Pluck multiple values for each object]
## Pluck multiple values for each object
If you want to extract **multiple values** for each object, you can use a nested `map()` to iterate over the keys. This results in each object being mapped to an array of values.
```js
const pluck ... | code_snippets | ||
a0815abb-d0b4-44a0-b50c-34ae8c1fe7ed | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pluck-values-from-object-array.md | unknown | b0d4aec8-eb02-47b0-8f7a-6fcdc38ba3bd | 1 | SemanticChunker@1.0.0 | 6586cd11d144785c06e2410c6f2bad08813f91e244b683d1f50b3895c994d2e8 | [Pluck a single value for each object]
## Pluck a single value for each object
All you need to do is use `Array.prototype.map()` to map the array of objects to the **value of the specified key** for each object.
```js
const pluck = (arr, key) => arr.map(i => i[key]);
const simpsons = [
{ name: 'Lisa', age: 8, user... | unknown | unknown | [Pluck a single value for each object]
## Pluck a single value for each object
All you need to do is use `Array.prototype.map()` to map the array of objects to the **value of the specified key** for each object.
```js
const pluck = (arr, key) => arr.map(i => i[key]);
const simpsons = [
{ name: 'Lisa', age: 8, user... | [Pluck a single value for each object]
## Pluck a single value for each object
All you need to do is use `Array.prototype.map()` to map the array of objects to the **value of the specified key** for each object.
```js
const pluck = (arr, key) => arr.map(i => i[key]);
const simpsons = [
{ name: 'Lisa', age: 8, user... | code_snippets | ||
25525a60-7dd6-444b-abd8-46691381e407 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-or-serialize-cookie.md | unknown | d5c59744-d9d4-41a2-a6aa-8aea06b9bc50 | 2 | SemanticChunker@1.0.0 | 214a1d4079778d29d64ad2a066ceedeed0a3bb5639cb9ae01ed2a9d16b5f160b | [Anatomy of a cookie > Parse a cookie]
## Parse a cookie
Knowing how a cookie string is structured allows us to work towards parsing it.
First, we'll break it down into **individual key-value pairs**, using `String.prototype.split()`. Then, using `Array.prototype.map()` and `String.prototype.split()` we'll **separat... | unknown | unknown | [Anatomy of a cookie > Parse a cookie]
## Parse a cookie
Knowing how a cookie string is structured allows us to work towards parsing it.
First, we'll break it down into **individual key-value pairs**, using `String.prototype.split()`. Then, using `Array.prototype.map()` and `String.prototype.split()` we'll **separat... | [Anatomy of a cookie > Parse a cookie]
## Parse a cookie
Knowing how a cookie string is structured allows us to work towards parsing it.
First, we'll break it down into **individual key-value pairs**, using `String.prototype.split()`. Then, using `Array.prototype.map()` and `String.prototype.split()` we'll **separat... | code_snippets | ||
27ed168b-5a36-40a3-8b99-c6ffb82811ff | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-or-serialize-cookie.md | unknown | d5c59744-d9d4-41a2-a6aa-8aea06b9bc50 | 1 | SemanticChunker@1.0.0 | 16b9353a0fd4027c798e04e915d9004ad736317c2264d872b13f6def5d4ea61b | [Anatomy of a cookie]
## Anatomy of a cookie
Before we can work with cookies, we need to understand how they are formatted. An HTTP Cookie header string is a **string of key-value pairs, separated by semicolons**. For example:
```js
const cookieString = document.cookie;
// 'foo=bar; equation=E%3Dmc%5E2'
/* This repr... | unknown | unknown | [Anatomy of a cookie]
## Anatomy of a cookie
Before we can work with cookies, we need to understand how they are formatted. An HTTP Cookie header string is a **string of key-value pairs, separated by semicolons**. For example:
```js
const cookieString = document.cookie;
// 'foo=bar; equation=E%3Dmc%5E2'
/* This repr... | [Anatomy of a cookie]
## Anatomy of a cookie
Before we can work with cookies, we need to understand how they are formatted. An HTTP Cookie header string is a **string of key-value pairs, separated by semicolons**. For example:
```js
const cookieString = document.cookie;
// 'foo=bar; equation=E%3Dmc%5E2'
/* This repr... | code_snippets | ||
348cfc6a-5dd2-4b20-bfde-02f940fb5506 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-or-serialize-cookie.md | unknown | d5c59744-d9d4-41a2-a6aa-8aea06b9bc50 | 3 | SemanticChunker@1.0.0 | a1909b3e772d5ab17cfa128834b08e2d3557cd06a72d200b99a69413579821f7 | [Anatomy of a cookie > Serialize a cookie]
## Serialize a cookie
Serializing a cookie is much more straightforward. Using **template literals** and `encodeURIComponent()` we can create the appropriate string.
```js
const serializeCookie = (name, val) =>
`${encodeURIComponent(name)}=${encodeURIComponent(val)}`;
ser... | unknown | unknown | [Anatomy of a cookie > Serialize a cookie]
## Serialize a cookie
Serializing a cookie is much more straightforward. Using **template literals** and `encodeURIComponent()` we can create the appropriate string.
```js
const serializeCookie = (name, val) =>
`${encodeURIComponent(name)}=${encodeURIComponent(val)}`;
ser... | [Anatomy of a cookie > Serialize a cookie]
## Serialize a cookie
Serializing a cookie is much more straightforward. Using **template literals** and `encodeURIComponent()` we can create the appropriate string.
```js
const serializeCookie = (name, val) =>
`${encodeURIComponent(name)}=${encodeURIComponent(val)}`;
ser... | code_snippets | ||
5b889915-bec9-4aff-af43-fe0102fd7ccf | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-or-serialize-cookie.md | unknown | d5c59744-d9d4-41a2-a6aa-8aea06b9bc50 | 0 | SemanticChunker@1.0.0 | 72dfca3e81bcc2907d2924ea49435d6ff78d30502289e006d9c6ecde2e98e5de | ---
title: Parse or serialize a cookie with JavaScript
shortTitle: Parse or serialize cookie
language: javascript
tags: [browser,string]
cover: purple-sunset-beach
excerpt: Learn how to parse or serialize a cookie with JavaScript, quickly and effectively.
listed: true
dateModified: 2024-01-12
---
Cookies are **small p... | unknown | unknown | ---
title: Parse or serialize a cookie with JavaScript
shortTitle: Parse or serialize cookie
language: javascript
tags: [browser,string]
cover: purple-sunset-beach
excerpt: Learn how to parse or serialize a cookie with JavaScript, quickly and effectively.
listed: true
dateModified: 2024-01-12
---
Cookies are **small p... | ---
title: Parse or serialize a cookie with JavaScript
shortTitle: Parse or serialize cookie
language: javascript
tags: [browser,string]
cover: purple-sunset-beach
excerpt: Learn how to parse or serialize a cookie with JavaScript, quickly and effectively.
listed: true
dateModified: 2024-01-12
---
Cookies are **small p... | code_snippets | ||
0a6322ce-bf27-479f-b3ae-5e8159b6cf0c | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-reverse-polish-notation.md | unknown | 6adf95b6-8ce4-40eb-b1aa-9150f7a7523c | 6 | SemanticChunker@1.0.0 | 246ba81bde813779dd91da948270a46dc7696f328f6f8c82d04d2a6cc9c9ddf2 | [Parse Reverse Polish Notation > Convert Infix Notation to RPN]
```js
// Define the operator precedence
const precedence = { '+': 1, '-': 1, '*': 2, '/': 2 };
const toRPN = expression => {
// Tokenize the expression, splitting by whitespace first and processing
// individual tokens to handle parentheses and negativ... | unknown | unknown | [Parse Reverse Polish Notation > Convert Infix Notation to RPN]
```js
// Define the operator precedence
const precedence = { '+': 1, '-': 1, '*': 2, '/': 2 };
const toRPN = expression => {
// Tokenize the expression, splitting by whitespace first and processing
// individual tokens to handle parentheses and negativ... | [Parse Reverse Polish Notation > Convert Infix Notation to RPN]
```js
// Define the operator precedence
const precedence = { '+': 1, '-': 1, '*': 2, '/': 2 };
const toRPN = expression => {
// Tokenize the expression, splitting by whitespace first and processing
// individual tokens to handle parentheses and negativ... | code_snippets | ||
146ba653-96ec-453f-beda-8c0ab5260916 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-reverse-polish-notation.md | unknown | 6adf95b6-8ce4-40eb-b1aa-9150f7a7523c | 5 | SemanticChunker@1.0.0 | 377affb00bb9406756d6628f5e46d892fb1bc8ef6d48cf046f3812e9ae577688 | [Parse Reverse Polish Notation > Convert Infix Notation to RPN]
## Convert Infix Notation to RPN
Converting an **infix expression to Reverse Polish Notation** is a bit more complicated than parsing RPN. However, this problem has been long solved by Edsger Dijkstra in the form of the [**shunting yard algorithm**](http... | unknown | unknown | [Parse Reverse Polish Notation > Convert Infix Notation to RPN]
## Convert Infix Notation to RPN
Converting an **infix expression to Reverse Polish Notation** is a bit more complicated than parsing RPN. However, this problem has been long solved by Edsger Dijkstra in the form of the [**shunting yard algorithm**](http... | [Parse Reverse Polish Notation > Convert Infix Notation to RPN]
## Convert Infix Notation to RPN
Converting an **infix expression to Reverse Polish Notation** is a bit more complicated than parsing RPN. However, this problem has been long solved by Edsger Dijkstra in the form of the [**shunting yard algorithm**](http... | code_snippets | ||
31a2b370-42bc-4fa7-ab53-99fdc841da30 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-reverse-polish-notation.md | unknown | 6adf95b6-8ce4-40eb-b1aa-9150f7a7523c | 0 | SemanticChunker@1.0.0 | b97230cdae2c2721ce57ed610f1c7ea45ac3406cb1ba3db56bc301684a714741 | ---
title: How can I parse Reverse Polish Notation in JavaScript?
shortTitle: Reverse Polish Notation
language: javascript
tags: [math,algorithm]
cover: flower-camera
excerpt: Parsing Reverse Polish Notation, also known as postfix notation, is a simple algorithm that can be implemented in JavaScript using a stack.
list... | unknown | unknown | ---
title: How can I parse Reverse Polish Notation in JavaScript?
shortTitle: Reverse Polish Notation
language: javascript
tags: [math,algorithm]
cover: flower-camera
excerpt: Parsing Reverse Polish Notation, also known as postfix notation, is a simple algorithm that can be implemented in JavaScript using a stack.
list... | ---
title: How can I parse Reverse Polish Notation in JavaScript?
shortTitle: Reverse Polish Notation
language: javascript
tags: [math,algorithm]
cover: flower-camera
excerpt: Parsing Reverse Polish Notation, also known as postfix notation, is a simple algorithm that can be implemented in JavaScript using a stack.
list... | code_snippets | ||
8705b7dc-6f57-477c-ae0f-25350ad3916b | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-reverse-polish-notation.md | unknown | 6adf95b6-8ce4-40eb-b1aa-9150f7a7523c | 1 | SemanticChunker@1.0.0 | e6b5b44eae890597cb454beebb61d93988d87e5812a9b52e8eb4c39ccc1a0caf | [Parse Reverse Polish Notation]
## Parse Reverse Polish Notation
Parsing Reverse Polish Notation isn't a particularly difficult task. The key lies in the **order of the operands and operators**. Whenever you encounter an operator, you're guaranteed to have two operands before it, either directly before it or further ... | unknown | unknown | [Parse Reverse Polish Notation]
## Parse Reverse Polish Notation
Parsing Reverse Polish Notation isn't a particularly difficult task. The key lies in the **order of the operands and operators**. Whenever you encounter an operator, you're guaranteed to have two operands before it, either directly before it or further ... | [Parse Reverse Polish Notation]
## Parse Reverse Polish Notation
Parsing Reverse Polish Notation isn't a particularly difficult task. The key lies in the **order of the operands and operators**. Whenever you encounter an operator, you're guaranteed to have two operands before it, either directly before it or further ... | code_snippets | ||
93a2d479-7cf3-412e-b869-ad236e574138 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-reverse-polish-notation.md | unknown | 6adf95b6-8ce4-40eb-b1aa-9150f7a7523c | 3 | SemanticChunker@1.0.0 | cbd8f300fcc852c52ae1ff93ce0c8a356c427d478b40b31aa1c31bc901942c17 | [Parse Reverse Polish Notation]
The trickiest part, if you can call it that, is the **order of operands when performing the operation**. We need to be careful about the order of the operands when popping them from the stack. As the first operand to be popped from the stack should be the second operand in the operation... | unknown | unknown | [Parse Reverse Polish Notation]
The trickiest part, if you can call it that, is the **order of operands when performing the operation**. We need to be careful about the order of the operands when popping them from the stack. As the first operand to be popped from the stack should be the second operand in the operation... | [Parse Reverse Polish Notation]
The trickiest part, if you can call it that, is the **order of operands when performing the operation**. We need to be careful about the order of the operands when popping them from the stack. As the first operand to be popped from the stack should be the second operand in the operation... | code_snippets | ||
965d6a99-2edb-4b9e-bd42-c7fc85f9b672 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-reverse-polish-notation.md | unknown | 6adf95b6-8ce4-40eb-b1aa-9150f7a7523c | 7 | SemanticChunker@1.0.0 | 1d7bb2fc04d18943143bc1300160c90d42993ef4f07970e88d33710ff2ade1e7 | [Parse Reverse Polish Notation > Convert Infix Notation to RPN]
The implementation is a bit more complex than the RPN parser, but it's still quite simple. We tokenize the expression, then reduce the tokens array to an output and stack array, following the rules of the shunting yard algorithm. Finally, we return the ou... | unknown | unknown | [Parse Reverse Polish Notation > Convert Infix Notation to RPN]
The implementation is a bit more complex than the RPN parser, but it's still quite simple. We tokenize the expression, then reduce the tokens array to an output and stack array, following the rules of the shunting yard algorithm. Finally, we return the ou... | [Parse Reverse Polish Notation > Convert Infix Notation to RPN]
The implementation is a bit more complex than the RPN parser, but it's still quite simple. We tokenize the expression, then reduce the tokens array to an output and stack array, following the rules of the shunting yard algorithm. Finally, we return the ou... | code_snippets | ||
9874353f-fe1d-402e-b2df-022027858740 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-reverse-polish-notation.md | unknown | 6adf95b6-8ce4-40eb-b1aa-9150f7a7523c | 8 | SemanticChunker@1.0.0 | 5397aab0e7650ccebf00e2e510d5d3a73a09c3e9be5774296f31c3715ed22fd0 | [Parse Reverse Polish Notation > Conclusion]
## Conclusion
In this article, we took a brief, yet enlightening look at parsing Reverse Polish Notation in JavaScript. We implemented a simple RPN parser using a stack and the four basic arithmetic operators. We then converted the RPN parser to parse Polish Notation by re... | unknown | unknown | [Parse Reverse Polish Notation > Conclusion]
## Conclusion
In this article, we took a brief, yet enlightening look at parsing Reverse Polish Notation in JavaScript. We implemented a simple RPN parser using a stack and the four basic arithmetic operators. We then converted the RPN parser to parse Polish Notation by re... | [Parse Reverse Polish Notation > Conclusion]
## Conclusion
In this article, we took a brief, yet enlightening look at parsing Reverse Polish Notation in JavaScript. We implemented a simple RPN parser using a stack and the four basic arithmetic operators. We then converted the RPN parser to parse Polish Notation by re... | code_snippets | ||
ea57404c-bebe-4c46-8d63-566713d65e47 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-reverse-polish-notation.md | unknown | 6adf95b6-8ce4-40eb-b1aa-9150f7a7523c | 4 | SemanticChunker@1.0.0 | f0711c9938aea97fe9d165e6ed675eeff264964f8545ab1ae5bb7e51ca2adaee | [Parse Reverse Polish Notation > Parse Polish Notation]
## Parse Polish Notation
**Polish Notation** (PN), also known as **prefix notation**, is very similar to Reverse Polish Notation, but the operators **precede their operands**. This means that the operator comes before the operands, which makes it easier to parse... | unknown | unknown | [Parse Reverse Polish Notation > Parse Polish Notation]
## Parse Polish Notation
**Polish Notation** (PN), also known as **prefix notation**, is very similar to Reverse Polish Notation, but the operators **precede their operands**. This means that the operator comes before the operands, which makes it easier to parse... | [Parse Reverse Polish Notation > Parse Polish Notation]
## Parse Polish Notation
**Polish Notation** (PN), also known as **prefix notation**, is very similar to Reverse Polish Notation, but the operators **precede their operands**. This means that the operator comes before the operands, which makes it easier to parse... | code_snippets | ||
ee47ed98-3acc-40a8-8528-22f433ff8e35 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/parse-reverse-polish-notation.md | unknown | 6adf95b6-8ce4-40eb-b1aa-9150f7a7523c | 2 | SemanticChunker@1.0.0 | eb5118d4c9744ce7140d66fbda681a4858842bd754e77f7cc0e4cbc6c0b91707 | [Parse Reverse Polish Notation]
```js
// Define the operands and their corresponding functions
const operands = {
'+': (b, a) => a + b,
'-': (b, a) => a - b,
'*': (b, a) => a * b,
'/': (b, a) => a / b
};
const parseRPN = expression => {
// If the expression is empty, return 0
if (!expression.trim()) return 0;
... | unknown | unknown | [Parse Reverse Polish Notation]
```js
// Define the operands and their corresponding functions
const operands = {
'+': (b, a) => a + b,
'-': (b, a) => a - b,
'*': (b, a) => a * b,
'/': (b, a) => a / b
};
const parseRPN = expression => {
// If the expression is empty, return 0
if (!expression.trim()) return 0;
... | [Parse Reverse Polish Notation]
```js
// Define the operands and their corresponding functions
const operands = {
'+': (b, a) => a + b,
'-': (b, a) => a - b,
'*': (b, a) => a * b,
'/': (b, a) => a / b
};
const parseRPN = expression => {
// If the expression is empty, return 0
if (!expression.trim()) return 0;
... | code_snippets | ||
cfbcea17-7a16-4890-a473-539522fd9118 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/prevent-string-being-escaped.md | unknown | 4bf9bffa-ed56-4d8c-95ff-f5818abf704b | 0 | SemanticChunker@1.0.0 | 1a264c39b0ecfc1881ecaeacd559436030a6db25a0440f56c615d178938030d8 | ---
title: Prevent a string from being escaped in JavaScript
shortTitle: Prevent string escaping
language: javascript
tags: [string]
cover: glass-blowing
excerpt: Strings in JavaScript can be escaped in various ways. But how do you prevent a string from being escaped? Here's a handy trick for that.
listed: true
dateMod... | unknown | unknown | ---
title: Prevent a string from being escaped in JavaScript
shortTitle: Prevent string escaping
language: javascript
tags: [string]
cover: glass-blowing
excerpt: Strings in JavaScript can be escaped in various ways. But how do you prevent a string from being escaped? Here's a handy trick for that.
listed: true
dateMod... | ---
title: Prevent a string from being escaped in JavaScript
shortTitle: Prevent string escaping
language: javascript
tags: [string]
cover: glass-blowing
excerpt: Strings in JavaScript can be escaped in various ways. But how do you prevent a string from being escaped? Here's a handy trick for that.
listed: true
dateMod... | code_snippets | ||
32b53683-e908-48fa-b06e-68d8f29fed99 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pretty-print-number-of-bytes.md | unknown | 0bc9471d-1c7e-4963-b2d1-fa20443e9dbf | 0 | SemanticChunker@1.0.0 | f4515572bc25814ac50f0439088af9276fe93d562510b41efc7deb8dc6acca13 | ---
title: Pretty print number of bytes
language: javascript
tags: [number]
cover: digital-nomad
excerpt: Convert a number in bytes to a human-readable string.
listed: true
dateModified: 2024-08-13
---
Converting a **numeric byte value** into a **human-readable string** is a pretty useful tool to have in your utility ... | unknown | unknown | ---
title: Pretty print number of bytes
language: javascript
tags: [number]
cover: digital-nomad
excerpt: Convert a number in bytes to a human-readable string.
listed: true
dateModified: 2024-08-13
---
Converting a **numeric byte value** into a **human-readable string** is a pretty useful tool to have in your utility ... | ---
title: Pretty print number of bytes
language: javascript
tags: [number]
cover: digital-nomad
excerpt: Convert a number in bytes to a human-readable string.
listed: true
dateModified: 2024-08-13
---
Converting a **numeric byte value** into a **human-readable string** is a pretty useful tool to have in your utility ... | code_snippets | ||
8862d435-5c0a-478c-9c58-1eb4202d0fc9 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pretty-print-json.md | unknown | db0dc00c-6a36-4c23-a2ad-24ee232dd3fd | 0 | SemanticChunker@1.0.0 | 6d02d312d174ee2384cb2aea47fae4aa3f3be4be00e5923788dfb58d291022ff | ---
title: Pretty-print a JSON object with JavaScript
shortTitle: Pretty-print JSON
language: javascript
tags: [object,json]
cover: memories-of-pineapple-3
excerpt: Pretty-printing JSON objects in pretty easy and customizable in JavaScript. Here's the gist of it.
listed: true
dateModified: 2022-07-30
---
Pretty-printi... | unknown | unknown | ---
title: Pretty-print a JSON object with JavaScript
shortTitle: Pretty-print JSON
language: javascript
tags: [object,json]
cover: memories-of-pineapple-3
excerpt: Pretty-printing JSON objects in pretty easy and customizable in JavaScript. Here's the gist of it.
listed: true
dateModified: 2022-07-30
---
Pretty-printi... | ---
title: Pretty-print a JSON object with JavaScript
shortTitle: Pretty-print JSON
language: javascript
tags: [object,json]
cover: memories-of-pineapple-3
excerpt: Pretty-printing JSON objects in pretty easy and customizable in JavaScript. Here's the gist of it.
listed: true
dateModified: 2022-07-30
---
Pretty-printi... | code_snippets | ||
164d195e-81e2-4dc2-b8c7-2a25300afdb8 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/prefix-css-property.md | unknown | edec0bb9-7621-4b71-8472-4b491dc881fb | 0 | SemanticChunker@1.0.0 | 40a9eaf09b2b9273233f21b720299ca4ed25f78d4ac3c50c2e418d250188909e | ---
title: Use JavaScript to prefix a CSS property based on the browser
shortTitle: Prefix CSS property
language: javascript
tags: [browser,css]
cover: cancel-typographer
excerpt: Not sure if you need to prefix a CSS property in order to use it? Here's a simple way to figure it out!
listed: true
dateModified: 2023-10-2... | unknown | unknown | ---
title: Use JavaScript to prefix a CSS property based on the browser
shortTitle: Prefix CSS property
language: javascript
tags: [browser,css]
cover: cancel-typographer
excerpt: Not sure if you need to prefix a CSS property in order to use it? Here's a simple way to figure it out!
listed: true
dateModified: 2023-10-2... | ---
title: Use JavaScript to prefix a CSS property based on the browser
shortTitle: Prefix CSS property
language: javascript
tags: [browser,css]
cover: cancel-typographer
excerpt: Not sure if you need to prefix a CSS property in order to use it? Here's a simple way to figure it out!
listed: true
dateModified: 2023-10-2... | code_snippets | ||
39192585-0a9c-4c58-acd2-dabd2b26f6c0 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/prefix-css-property.md | unknown | edec0bb9-7621-4b71-8472-4b491dc881fb | 1 | SemanticChunker@1.0.0 | aed159d2075eb82e3ae6a495a5ec0436ea5b125d4123a9a2e6515f97524356b5 | Prefixed properties can be checked, using the **camel-cased attribute** of the `CSSStyleDeclaration` interface. You can use `String.prototype.charAt()` and `String.prototype.toUpperCase()` to **capitalize the property name**, which will be appended to the vendor prefix string.
```js
const prop = 'appearance';
const pr... | unknown | unknown | Prefixed properties can be checked, using the **camel-cased attribute** of the `CSSStyleDeclaration` interface. You can use `String.prototype.charAt()` and `String.prototype.toUpperCase()` to **capitalize the property name**, which will be appended to the vendor prefix string.
```js
const prop = 'appearance';
const pr... | Prefixed properties can be checked, using the **camel-cased attribute** of the `CSSStyleDeclaration` interface. You can use `String.prototype.charAt()` and `String.prototype.toUpperCase()` to **capitalize the property name**, which will be appended to the vendor prefix string.
```js
const prop = 'appearance';
const pr... | code_snippets | ||
195a8126-7ded-48e4-bbf9-f3c4701dd20b | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/prefers-color-scheme.md | unknown | 7104ea03-1d5c-4673-b76d-e69e121afb0a | 1 | SemanticChunker@1.0.0 | c023a4bd513a8d10dbac88367b4538b273dec3d60c44991e91177aa1d315bdd2 | [Check if user prefers a dark color scheme]
## Check if user prefers a dark color scheme
Combining the media query with the `Window.matchMedia()` method allows us to check if the user has selected a dark color scheme (`'dark'`) in their operating system settings.
```js
const prefersDarkColorScheme = () =>
window &&... | unknown | unknown | [Check if user prefers a dark color scheme]
## Check if user prefers a dark color scheme
Combining the media query with the `Window.matchMedia()` method allows us to check if the user has selected a dark color scheme (`'dark'`) in their operating system settings.
```js
const prefersDarkColorScheme = () =>
window &&... | [Check if user prefers a dark color scheme]
## Check if user prefers a dark color scheme
Combining the media query with the `Window.matchMedia()` method allows us to check if the user has selected a dark color scheme (`'dark'`) in their operating system settings.
```js
const prefersDarkColorScheme = () =>
window &&... | code_snippets | ||
23bbb1f6-af01-494e-8914-11416e848336 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/prefers-color-scheme.md | unknown | 7104ea03-1d5c-4673-b76d-e69e121afb0a | 0 | SemanticChunker@1.0.0 | a700b53e59de006a2ef648c9798369a562bb901cb82230f426a1772eb46638b1 | ---
title: Detect user color scheme preference in JavaScript
language: javascript
tags: [browser]
cover: dark-mode
excerpt: Use a media query to check if the user prefers a light or dark color scheme.
listed: true
dateModified: 2023-11-05
---
The recently introduced `prefers-color-scheme` media query allows us to chec... | unknown | unknown | ---
title: Detect user color scheme preference in JavaScript
language: javascript
tags: [browser]
cover: dark-mode
excerpt: Use a media query to check if the user prefers a light or dark color scheme.
listed: true
dateModified: 2023-11-05
---
The recently introduced `prefers-color-scheme` media query allows us to chec... | ---
title: Detect user color scheme preference in JavaScript
language: javascript
tags: [browser]
cover: dark-mode
excerpt: Use a media query to check if the user prefers a light or dark color scheme.
listed: true
dateModified: 2023-11-05
---
The recently introduced `prefers-color-scheme` media query allows us to chec... | code_snippets | ||
4d203ed1-788e-4e01-bf20-2f557a663053 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/prefers-color-scheme.md | unknown | 7104ea03-1d5c-4673-b76d-e69e121afb0a | 2 | SemanticChunker@1.0.0 | c9f088433f733d763e66d7682ce5f873d1e8b475efa0e281a06b004dfeb4e5fa | [Check if user prefers a dark color scheme > Check if user prefers a light color scheme]
## Check if user prefers a light color scheme
The same technique can be used for checking if the user prefers a light color scheme. Bear in mind, however, that `'light'` is the **default value** for the `prefers-color-scheme` med... | unknown | unknown | [Check if user prefers a dark color scheme > Check if user prefers a light color scheme]
## Check if user prefers a light color scheme
The same technique can be used for checking if the user prefers a light color scheme. Bear in mind, however, that `'light'` is the **default value** for the `prefers-color-scheme` med... | [Check if user prefers a dark color scheme > Check if user prefers a light color scheme]
## Check if user prefers a light color scheme
The same technique can be used for checking if the user prefers a light color scheme. Bear in mind, however, that `'light'` is the **default value** for the `prefers-color-scheme` med... | code_snippets | ||
6f1e3034-b251-4664-b03a-eb263a99287e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/prefix-postfix-operators.md | unknown | 262cb5db-0b23-453b-beb3-c07ce4527d1b | 0 | SemanticChunker@1.0.0 | 27b5a8c72ad365372d740657e8787d7f35d905e604fff8cd4aa578da35e0f1c6 | ---
title: What is the difference between prefix and postfix operators?
shortTitle: Prefix and postfix operators
language: javascript
tags: [math]
cover: plant-candle
excerpt: While both the prefix and postfix operators increment a value, the resulting value of the expression is very different.
listed: true
dateModifie... | unknown | unknown | ---
title: What is the difference between prefix and postfix operators?
shortTitle: Prefix and postfix operators
language: javascript
tags: [math]
cover: plant-candle
excerpt: While both the prefix and postfix operators increment a value, the resulting value of the expression is very different.
listed: true
dateModifie... | ---
title: What is the difference between prefix and postfix operators?
shortTitle: Prefix and postfix operators
language: javascript
tags: [math]
cover: plant-candle
excerpt: While both the prefix and postfix operators increment a value, the resulting value of the expression is very different.
listed: true
dateModifie... | code_snippets | ||
59b66f9b-34aa-40e7-9e40-7449ab233942 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/prime-factors.md | unknown | dea4cc61-4c66-4b72-9dc4-e42ede36a8ca | 0 | SemanticChunker@1.0.0 | c11371b7af724168910540f25db2d66e0665da880ef857e43ead001b3f155d73 | ---
title: Find the prime factors of a number in JavaScript
shortTitle: Prime factors
language: javascript
tags: [math,algorithm]
cover: dark-leaves-3
excerpt: Find the prime factors of a number using trial division in JavaScript.
listed: true
dateModified: 2024-02-23
---
The **prime factors** of a number are the prim... | unknown | unknown | ---
title: Find the prime factors of a number in JavaScript
shortTitle: Prime factors
language: javascript
tags: [math,algorithm]
cover: dark-leaves-3
excerpt: Find the prime factors of a number using trial division in JavaScript.
listed: true
dateModified: 2024-02-23
---
The **prime factors** of a number are the prim... | ---
title: Find the prime factors of a number in JavaScript
shortTitle: Prime factors
language: javascript
tags: [math,algorithm]
cover: dark-leaves-3
excerpt: Find the prime factors of a number using trial division in JavaScript.
listed: true
dateModified: 2024-02-23
---
The **prime factors** of a number are the prim... | code_snippets | ||
4999d370-56a0-462b-8d1b-5296c213fcb1 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pluralize-string.md | unknown | d7affc0b-3f81-4c20-b6f9-f75815fc96d6 | 0 | SemanticChunker@1.0.0 | a36ac72a807cacbda461197beacf537aaf930eb0e97a2d5924c4c4ae116540f6 | ---
title: Pluralize a JavaScript string
description: Pluralize string
language: javascript
tags: [string]
cover: shell-focus
excerpt: Learn how to pluralize a string in JavaScript based on a number.
listed: true
dateModified: 2024-06-02
---
Tasks involving language and localization are generally more complex than the... | unknown | unknown | ---
title: Pluralize a JavaScript string
description: Pluralize string
language: javascript
tags: [string]
cover: shell-focus
excerpt: Learn how to pluralize a string in JavaScript based on a number.
listed: true
dateModified: 2024-06-02
---
Tasks involving language and localization are generally more complex than the... | ---
title: Pluralize a JavaScript string
description: Pluralize string
language: javascript
tags: [string]
cover: shell-focus
excerpt: Learn how to pluralize a string in JavaScript based on a number.
listed: true
dateModified: 2024-06-02
---
Tasks involving language and localization are generally more complex than the... | code_snippets | ||
7696310e-17e4-4115-b1e5-927f89c841eb | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pluralize-string.md | unknown | d7affc0b-3f81-4c20-b6f9-f75815fc96d6 | 1 | SemanticChunker@1.0.0 | 2ad6d1d1b53d656f3dc971ad0b49b4e06e0212f219840485f823a389098371cf | [Check if string should be pluralized]
## Check if string should be pluralized
Focusing on **English**, the rules are relatively simple: if the number is not `1`, the word should be pluralized. We can write a simple function to decide whether to pluralize a word based on a number, using `Math.abs()`, so we can handle... | unknown | unknown | [Check if string should be pluralized]
## Check if string should be pluralized
Focusing on **English**, the rules are relatively simple: if the number is not `1`, the word should be pluralized. We can write a simple function to decide whether to pluralize a word based on a number, using `Math.abs()`, so we can handle... | [Check if string should be pluralized]
## Check if string should be pluralized
Focusing on **English**, the rules are relatively simple: if the number is not `1`, the word should be pluralized. We can write a simple function to decide whether to pluralize a word based on a number, using `Math.abs()`, so we can handle... | code_snippets | ||
9c325d6c-506b-4ecc-a8c7-530cb2b579cd | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pluralize-string.md | unknown | d7affc0b-3f81-4c20-b6f9-f75815fc96d6 | 2 | SemanticChunker@1.0.0 | 4db3542bda0e5750918cf7e6d92c00f6a9e07c4c483248d8e6b78feb1f94f0cc | [Check if string should be pluralized > Pluralize string based on a number]
## Pluralize string based on a number
The plural form of most words is simply the singular form with an _s_ added to the end. However, there are **exceptions**, such as _person_ becoming _people_ and _radius_ becoming _radii_. For such cases,... | unknown | unknown | [Check if string should be pluralized > Pluralize string based on a number]
## Pluralize string based on a number
The plural form of most words is simply the singular form with an _s_ added to the end. However, there are **exceptions**, such as _person_ becoming _people_ and _radius_ becoming _radii_. For such cases,... | [Check if string should be pluralized > Pluralize string based on a number]
## Pluralize string based on a number
The plural form of most words is simply the singular form with an _s_ added to the end. However, there are **exceptions**, such as _person_ becoming _people_ and _radius_ becoming _radii_. For such cases,... | code_snippets | ||
fe83d676-ad15-4bb5-b548-b03e0e6565b3 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pluralize-string.md | unknown | d7affc0b-3f81-4c20-b6f9-f75815fc96d6 | 3 | SemanticChunker@1.0.0 | f14047dfbf74cac74a7f3b341bf55938508e6650b25eecd655068e737a154bbf | [Check if string should be pluralized > Pluralize strings using a dictionary]
## Pluralize strings using a dictionary
This works, but is a little cumbersome to use. We can improve it by using a **dictionary** to store the plural forms of words. This way, we can easily look up the plural form of a word based on the in... | unknown | unknown | [Check if string should be pluralized > Pluralize strings using a dictionary]
## Pluralize strings using a dictionary
This works, but is a little cumbersome to use. We can improve it by using a **dictionary** to store the plural forms of words. This way, we can easily look up the plural form of a word based on the in... | [Check if string should be pluralized > Pluralize strings using a dictionary]
## Pluralize strings using a dictionary
This works, but is a little cumbersome to use. We can improve it by using a **dictionary** to store the plural forms of words. This way, we can easily look up the plural form of a word based on the in... | code_snippets | ||
1b3253d2-c03c-4cf5-82af-e34956f9b96b | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 17 | SemanticChunker@1.0.0 | 6e79c6dace21e7d6ff9da6134a01b39411e7485abb738f8a521bbd520618a811 | [Definition > Addendum: Code summary]
## Addendum: Code summary
If you're looking for the **complete implementation**, here's a summary of all the steps combined, as well as the main function that ties everything together:
<details>
<summary>View the complete implementation</summary> | unknown | unknown | [Definition > Addendum: Code summary]
## Addendum: Code summary
If you're looking for the **complete implementation**, here's a summary of all the steps combined, as well as the main function that ties everything together:
<details>
<summary>View the complete implementation</summary> | [Definition > Addendum: Code summary]
## Addendum: Code summary
If you're looking for the **complete implementation**, here's a summary of all the steps combined, as well as the main function that ties everything together:
<details>
<summary>View the complete implementation</summary> | code_snippets | ||
2038c463-41e7-4c8d-895a-39a4699c6372 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 13 | SemanticChunker@1.0.0 | fb3d999998073885a3a0f5ac9c912201b4ac0ae35ecb8894f0bc2c60425bed88 | [Step-by-step implementation > Step 4]
```js
const step4 = word => {
const rules = {
al: '',
ance: '',
ence: '',
er: '',
ic: '',
able: '',
ible: '',
ant: '',
ement: '',
ment: '',
ent: '',
ion: '',
ou: '',
ism: '',
ate: '',
iti: '',
ous: '',
ive: '',
ize: '',
};
for (const [suffix, replacement] o... | unknown | unknown | [Step-by-step implementation > Step 4]
```js
const step4 = word => {
const rules = {
al: '',
ance: '',
ence: '',
er: '',
ic: '',
able: '',
ible: '',
ant: '',
ement: '',
ment: '',
ent: '',
ion: '',
ou: '',
ism: '',
ate: '',
iti: '',
ous: '',
ive: '',
ize: '',
};
for (const [suffix, replacement] o... | [Step-by-step implementation > Step 4]
```js
const step4 = word => {
const rules = {
al: '',
ance: '',
ence: '',
er: '',
ic: '',
able: '',
ible: '',
ant: '',
ement: '',
ment: '',
ent: '',
ion: '',
ou: '',
ism: '',
ate: '',
iti: '',
ous: '',
ive: '',
ize: '',
};
for (const [suffix, replacement] o... | code_snippets | ||
27213c3a-60f7-4df8-b45f-866fb5dbff69 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 3 | SemanticChunker@1.0.0 | 367c816bbb43bb1689347f8140df4e28fd3574e2207962c236b5612a74c70495 | [Definition > Step-by-step implementation]
## Step-by-step implementation
Having covered the terminology, let's jump in to the implementation. Each step will be presented as a table of rules, followed by a code snippet that implements them, some examples and a short explanation.
> [!IMPORTANT]
>
> This implementatio... | unknown | unknown | [Definition > Step-by-step implementation]
## Step-by-step implementation
Having covered the terminology, let's jump in to the implementation. Each step will be presented as a table of rules, followed by a code snippet that implements them, some examples and a short explanation.
> [!IMPORTANT]
>
> This implementatio... | [Definition > Step-by-step implementation]
## Step-by-step implementation
Having covered the terminology, let's jump in to the implementation. Each step will be presented as a table of rules, followed by a code snippet that implements them, some examples and a short explanation.
> [!IMPORTANT]
>
> This implementatio... | code_snippets | ||
2caaef5d-846b-49b9-97d8-e744a2e0778d | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 1 | SemanticChunker@1.0.0 | 44b1f9c9ba582ce3cc13e67c81c0f3865b5b2bab437fac34710e12440f96a2bd | [Definition]
## Definition
The **Porter stemming algorithm** was devised by Martin F. Porter in 1980 (that's 45 years ago). In the paper he describes a set of steps for stripping English words of common suffixes that depart little to no meaning, reducing them to their bases forms, a process known as **stemming**.
Th... | unknown | unknown | [Definition]
## Definition
The **Porter stemming algorithm** was devised by Martin F. Porter in 1980 (that's 45 years ago). In the paper he describes a set of steps for stripping English words of common suffixes that depart little to no meaning, reducing them to their bases forms, a process known as **stemming**.
Th... | [Definition]
## Definition
The **Porter stemming algorithm** was devised by Martin F. Porter in 1980 (that's 45 years ago). In the paper he describes a set of steps for stripping English words of common suffixes that depart little to no meaning, reducing them to their bases forms, a process known as **stemming**.
Th... | code_snippets | ||
32013b5b-a894-4448-80eb-829a503ef87b | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 11 | SemanticChunker@1.0.0 | 7fcd3f34a7182ce22d94f1e11ce29c04dbeb28e85217a47ab1ab89b01a2e262a | [Step-by-step implementation > Step 3]
### Step 3
Step 3 is also concerned with removing **common suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>0) ICATE -> IC` | `TRIPLICATE -> TRIPLIC` |
| `(m>0) ATIVE -> ` | `FORMATIVE -> FORM` |
| `(m>0) ALIZE -> AL` | `FORMALIZE -> FORMAL` |
|... | unknown | unknown | [Step-by-step implementation > Step 3]
### Step 3
Step 3 is also concerned with removing **common suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>0) ICATE -> IC` | `TRIPLICATE -> TRIPLIC` |
| `(m>0) ATIVE -> ` | `FORMATIVE -> FORM` |
| `(m>0) ALIZE -> AL` | `FORMALIZE -> FORMAL` |
|... | [Step-by-step implementation > Step 3]
### Step 3
Step 3 is also concerned with removing **common suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>0) ICATE -> IC` | `TRIPLICATE -> TRIPLIC` |
| `(m>0) ATIVE -> ` | `FORMATIVE -> FORM` |
| `(m>0) ALIZE -> AL` | `FORMALIZE -> FORMAL` |
|... | code_snippets | ||
4284098e-07fb-4cc6-b103-e55cc0c8e9b2 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 5 | SemanticChunker@1.0.0 | d8a43f9b77e48f24e1e41460bbe762b55142c4ff496c07bd3ae53c54bfdf9172 | [Step-by-step implementation > Step 1a]
### Step 1a
Step 1a is concerned with the removal of **plural form suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `SSES -> SS` | `CARESSES -> CARESS` |
| `IES -> I` | `PONIES -> PONI` <br/> `TIES -> TI` |
| `SS -> SS` | `CARESS -> CARESS` |
| `S ... | unknown | unknown | [Step-by-step implementation > Step 1a]
### Step 1a
Step 1a is concerned with the removal of **plural form suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `SSES -> SS` | `CARESSES -> CARESS` |
| `IES -> I` | `PONIES -> PONI` <br/> `TIES -> TI` |
| `SS -> SS` | `CARESS -> CARESS` |
| `S ... | [Step-by-step implementation > Step 1a]
### Step 1a
Step 1a is concerned with the removal of **plural form suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `SSES -> SS` | `CARESSES -> CARESS` |
| `IES -> I` | `PONIES -> PONI` <br/> `TIES -> TI` |
| `SS -> SS` | `CARESS -> CARESS` |
| `S ... | code_snippets | ||
50214ee4-38ed-4ed3-a70e-3005998bdf77 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 20 | SemanticChunker@1.0.0 | 9e31171ef307278eb1303d80dd314295a724b5b6f75fbbe2c3fa59b7f9f32c3a | [Definition > Addendum: Code summary]
```js
// [continued: part 2]
const step4 = word => {
const rules = {
al: '',
ance: '',
ence: '',
er: '',
ic: '',
able: '',
ible: '',
ant: '',
ement: '',
ment: '',
ent: '',
ion: '',
ou: '',
ism: '',
ate: '',
iti: '',
ous: '',
ive: '',
ize: '',
};
for (const [... | unknown | unknown | [Definition > Addendum: Code summary]
```js
// [continued: part 2]
const step4 = word => {
const rules = {
al: '',
ance: '',
ence: '',
er: '',
ic: '',
able: '',
ible: '',
ant: '',
ement: '',
ment: '',
ent: '',
ion: '',
ou: '',
ism: '',
ate: '',
iti: '',
ous: '',
ive: '',
ize: '',
};
for (const [... | [Definition > Addendum: Code summary]
```js
// [continued: part 2]
const step4 = word => {
const rules = {
al: '',
ance: '',
ence: '',
er: '',
ic: '',
able: '',
ible: '',
ant: '',
ement: '',
ment: '',
ent: '',
ion: '',
ou: '',
ism: '',
ate: '',
iti: '',
ous: '',
ive: '',
ize: '',
};
for (const [... | code_snippets | ||
66936a8a-b60b-46ce-84c5-b3563be267a3 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 12 | SemanticChunker@1.0.0 | a80f776612f591bbc1cf53cd69945d9572495a00e51ff1e7686ccd5acd5bbfbd | [Step-by-step implementation > Step 4]
### Step 4
Step 4 is also concerned with removing **common suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>1) AL -> ` | `REVIVAL -> REVIV` |
| `(m>1) ANCE -> ` | `ALLOWANCE -> ALLOW` |
| `(m>1) ENCE -> ` | `INFERENCE -> INFER` |
| `(m>1) ER -> ... | unknown | unknown | [Step-by-step implementation > Step 4]
### Step 4
Step 4 is also concerned with removing **common suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>1) AL -> ` | `REVIVAL -> REVIV` |
| `(m>1) ANCE -> ` | `ALLOWANCE -> ALLOW` |
| `(m>1) ENCE -> ` | `INFERENCE -> INFER` |
| `(m>1) ER -> ... | [Step-by-step implementation > Step 4]
### Step 4
Step 4 is also concerned with removing **common suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>1) AL -> ` | `REVIVAL -> REVIV` |
| `(m>1) ANCE -> ` | `ALLOWANCE -> ALLOW` |
| `(m>1) ENCE -> ` | `INFERENCE -> INFER` |
| `(m>1) ER -> ... | code_snippets | ||
6a6fa754-9827-4540-a4c0-72cfeda153b4 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 14 | SemanticChunker@1.0.0 | 16376d7011b7e5b7b7f6bcfdcb6cc04ba4b34eac57df7318b6499e1f37dfa813 | [Step-by-step implementation > Step 5a]
### Step 5a
Step 5a is concerned with **common suffix adjustments**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>1) E -> ` | `PROBATE -> PROBAT` <br/> `RATE -> RATE` |
| `(m=1 and not *o) E -> ` | `CEASE -> CEAS` |
```js
const step5a = word => {
if ... | unknown | unknown | [Step-by-step implementation > Step 5a]
### Step 5a
Step 5a is concerned with **common suffix adjustments**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>1) E -> ` | `PROBATE -> PROBAT` <br/> `RATE -> RATE` |
| `(m=1 and not *o) E -> ` | `CEASE -> CEAS` |
```js
const step5a = word => {
if ... | [Step-by-step implementation > Step 5a]
### Step 5a
Step 5a is concerned with **common suffix adjustments**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>1) E -> ` | `PROBATE -> PROBAT` <br/> `RATE -> RATE` |
| `(m=1 and not *o) E -> ` | `CEASE -> CEAS` |
```js
const step5a = word => {
if ... | code_snippets | ||
712e5bc8-3177-4d9e-886a-848927b48282 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 0 | SemanticChunker@1.0.0 | 661e8c13de0107bcf282e12eaad9f486c6f8f561dcdfbfe95df265f1311809e3 | ---
title: Implementing the Porter stemming algorithm in JavaScript
shortTitle: Porter stemming algorithm
language: javascript
tags: [algorithm,string,regexp]
cover: touch-flower
excerpt: Learn how to implement the Porter stemming algorithm in JavaScript, a simple algorithm for stripping English words of common suffixe... | unknown | unknown | ---
title: Implementing the Porter stemming algorithm in JavaScript
shortTitle: Porter stemming algorithm
language: javascript
tags: [algorithm,string,regexp]
cover: touch-flower
excerpt: Learn how to implement the Porter stemming algorithm in JavaScript, a simple algorithm for stripping English words of common suffixe... | ---
title: Implementing the Porter stemming algorithm in JavaScript
shortTitle: Porter stemming algorithm
language: javascript
tags: [algorithm,string,regexp]
cover: touch-flower
excerpt: Learn how to implement the Porter stemming algorithm in JavaScript, a simple algorithm for stripping English words of common suffixe... | code_snippets | ||
74011203-b8d8-426c-b0c9-ccecce97ba4e | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 16 | SemanticChunker@1.0.0 | eb68592222fa588857eb5eaf24c09835d1d1155d91f5b0eb47b91554fec4b976 | [Definition > Conclusion]
## Conclusion
Wow, that was quite a lot to absorb! Putting everything together will give you a basic implementation of the Porter stemming algorithm. It's a great starting point if you're looking to get into natural language processing. Give it a go! | unknown | unknown | [Definition > Conclusion]
## Conclusion
Wow, that was quite a lot to absorb! Putting everything together will give you a basic implementation of the Porter stemming algorithm. It's a great starting point if you're looking to get into natural language processing. Give it a go! | [Definition > Conclusion]
## Conclusion
Wow, that was quite a lot to absorb! Putting everything together will give you a basic implementation of the Porter stemming algorithm. It's a great starting point if you're looking to get into natural language processing. Give it a go! | code_snippets | ||
82a67468-6130-404d-a8b0-d6a1305008c5 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 18 | SemanticChunker@1.0.0 | 7941218ff6fbd29a3e2953a43cc17b93aa0e1607bda59fe15b6e1e60a5ea344b | [Definition > Addendum: Code summary]
```js
// c - consonant
const consonant = '[^aeiou]';
// v - vowel
const vowel = '[aeiouy]';
// C - consonant sequence
const consonants = '(' + consonant + '[^aeiouy]*)';
// V - vowel sequence
const vowels = '(' + vowel + '[aeiou]*)';
// m > 0
const mGreaterThanZero = new RegExp(
... | unknown | unknown | [Definition > Addendum: Code summary]
```js
// c - consonant
const consonant = '[^aeiou]';
// v - vowel
const vowel = '[aeiouy]';
// C - consonant sequence
const consonants = '(' + consonant + '[^aeiouy]*)';
// V - vowel sequence
const vowels = '(' + vowel + '[aeiou]*)';
// m > 0
const mGreaterThanZero = new RegExp(
... | [Definition > Addendum: Code summary]
```js
// c - consonant
const consonant = '[^aeiou]';
// v - vowel
const vowel = '[aeiouy]';
// C - consonant sequence
const consonants = '(' + consonant + '[^aeiouy]*)';
// V - vowel sequence
const vowels = '(' + vowel + '[aeiou]*)';
// m > 0
const mGreaterThanZero = new RegExp(
... | code_snippets | ||
82c774ec-2811-4372-a221-46bdb93f8c63 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 4 | SemanticChunker@1.0.0 | 15a2c649b0ebb8921b93aa0ccee1fa76dbbc23aaf7b905a46886613479055669 | [Step-by-step implementation > Common patterns]
### Common patterns
Before we begin, let's define some **common regular expression patterns** that we'll use throughout the implementation:
```js
// c - consonant
const consonant = '[^aeiou]';
// v - vowel
const vowel = '[aeiouy]';
// C - consonant sequence
const conso... | unknown | unknown | [Step-by-step implementation > Common patterns]
### Common patterns
Before we begin, let's define some **common regular expression patterns** that we'll use throughout the implementation:
```js
// c - consonant
const consonant = '[^aeiou]';
// v - vowel
const vowel = '[aeiouy]';
// C - consonant sequence
const conso... | [Step-by-step implementation > Common patterns]
### Common patterns
Before we begin, let's define some **common regular expression patterns** that we'll use throughout the implementation:
```js
// c - consonant
const consonant = '[^aeiou]';
// v - vowel
const vowel = '[aeiouy]';
// C - consonant sequence
const conso... | code_snippets | ||
b43ff1c1-1935-4805-be8f-8fe1e8f10e75 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 6 | SemanticChunker@1.0.0 | 321048a69793c4ada0c03dab8eae5f974f53125e6c9fd0222936b66aa2c6a566 | [Step-by-step implementation > Step 1b]
### Step 1b
Step 1b is concerned with the removal of **past tenses and gerunds**. It also deals with restoring the prefix to its true form after suffix removal. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>0) EED -> EE` | `FEED -> FEED` <br/> `AGREED -... | unknown | unknown | [Step-by-step implementation > Step 1b]
### Step 1b
Step 1b is concerned with the removal of **past tenses and gerunds**. It also deals with restoring the prefix to its true form after suffix removal. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>0) EED -> EE` | `FEED -> FEED` <br/> `AGREED -... | [Step-by-step implementation > Step 1b]
### Step 1b
Step 1b is concerned with the removal of **past tenses and gerunds**. It also deals with restoring the prefix to its true form after suffix removal. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>0) EED -> EE` | `FEED -> FEED` <br/> `AGREED -... | code_snippets | ||
c5b5c3fd-b87d-4858-be3b-fe0d3dfcdb06 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 2 | SemanticChunker@1.0.0 | 1ab72f74a7f20c99c7f0214dac505ea479ab28cc88a72bccabd060eeb08b1192 | [Definition > Terminology]
## Terminology
We'll brush up on the **terminology**, as described in the original paper, to make it a little easier to follow along.
A **consonant** in a word is a letter other than A, E, I, O or U, and other
than Y preceded by a consonant. If a letter is not a consonant, it is a **vowel*... | unknown | unknown | [Definition > Terminology]
## Terminology
We'll brush up on the **terminology**, as described in the original paper, to make it a little easier to follow along.
A **consonant** in a word is a letter other than A, E, I, O or U, and other
than Y preceded by a consonant. If a letter is not a consonant, it is a **vowel*... | [Definition > Terminology]
## Terminology
We'll brush up on the **terminology**, as described in the original paper, to make it a little easier to follow along.
A **consonant** in a word is a letter other than A, E, I, O or U, and other
than Y preceded by a consonant. If a letter is not a consonant, it is a **vowel*... | code_snippets | ||
d79e5795-191f-4513-9354-da7a61616671 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 15 | SemanticChunker@1.0.0 | 8388735dd7699fc9a0e6bb424a7d38d5f7236436ba0245d39ee8dcf5134e16f3 | [Step-by-step implementation > Step 5b]
### Step 5b
Step 5b is concerned with replacing `-ll` **suffixes** with `-l`. The rule is as follows:
| Rule | Example |
|------|---------|
| `(m>1 and *d and *L)`<br/>`-> single letter` | `CONTROLL -> CONTROL` <br/> `ROLL -> ROLL` |
```js
const step5b = word => {
if (
word... | unknown | unknown | [Step-by-step implementation > Step 5b]
### Step 5b
Step 5b is concerned with replacing `-ll` **suffixes** with `-l`. The rule is as follows:
| Rule | Example |
|------|---------|
| `(m>1 and *d and *L)`<br/>`-> single letter` | `CONTROLL -> CONTROL` <br/> `ROLL -> ROLL` |
```js
const step5b = word => {
if (
word... | [Step-by-step implementation > Step 5b]
### Step 5b
Step 5b is concerned with replacing `-ll` **suffixes** with `-l`. The rule is as follows:
| Rule | Example |
|------|---------|
| `(m>1 and *d and *L)`<br/>`-> single letter` | `CONTROLL -> CONTROL` <br/> `ROLL -> ROLL` |
```js
const step5b = word => {
if (
word... | code_snippets | ||
dc9038bf-d3bf-4b83-a229-ced396bf200c | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 19 | SemanticChunker@1.0.0 | 838784d55625be780a10522daf004174ce2704cc8cbfdc5658b81522fd5d3a25 | [Definition > Addendum: Code summary]
```js
// [continued: part 1]
const step2 = word => {
const rules = {
ational: 'ate',
tional: 'tion',
enci: 'ence',
anci: 'ance',
izer: 'ize',
abli: 'able',
alli: 'al',
entli: 'ent',
eli: 'e',
ousli: 'ous',
ization: 'ize',
ation: 'ate',
ator: 'ate',
alism: 'al',
ive... | unknown | unknown | [Definition > Addendum: Code summary]
```js
// [continued: part 1]
const step2 = word => {
const rules = {
ational: 'ate',
tional: 'tion',
enci: 'ence',
anci: 'ance',
izer: 'ize',
abli: 'able',
alli: 'al',
entli: 'ent',
eli: 'e',
ousli: 'ous',
ization: 'ize',
ation: 'ate',
ator: 'ate',
alism: 'al',
ive... | [Definition > Addendum: Code summary]
```js
// [continued: part 1]
const step2 = word => {
const rules = {
ational: 'ate',
tional: 'tion',
enci: 'ence',
anci: 'ance',
izer: 'ize',
abli: 'able',
alli: 'al',
entli: 'ent',
eli: 'e',
ousli: 'ous',
ization: 'ize',
ation: 'ate',
ator: 'ate',
alism: 'al',
ive... | code_snippets | ||
e0b11ec3-55c9-4ad7-90db-9bc864b9ca00 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 9 | SemanticChunker@1.0.0 | 8979884a716a83ca66421f013c47efa1b63dfea91aa5b78999a16f502bd0baa4 | [Step-by-step implementation > Step 2]
### Step 2
Step 2 is concerned with the removal of **common suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>0) ATIONAL -> ATE` | `RELATIONAL -> RELATE` |
| `(m>0) TIONAL -> TION` | `CONDITIONAL -> CONDITION` <br/> `RATIONAL -> RATIONAL` |
| `(m... | unknown | unknown | [Step-by-step implementation > Step 2]
### Step 2
Step 2 is concerned with the removal of **common suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>0) ATIONAL -> ATE` | `RELATIONAL -> RELATE` |
| `(m>0) TIONAL -> TION` | `CONDITIONAL -> CONDITION` <br/> `RATIONAL -> RATIONAL` |
| `(m... | [Step-by-step implementation > Step 2]
### Step 2
Step 2 is concerned with the removal of **common suffixes**. The rules are as follows:
| Rule | Example |
|------|---------|
| `(m>0) ATIONAL -> ATE` | `RELATIONAL -> RELATE` |
| `(m>0) TIONAL -> TION` | `CONDITIONAL -> CONDITION` <br/> `RATIONAL -> RATIONAL` |
| `(m... | code_snippets | ||
ece0bc53-608d-4fe5-ac28-8ecf14d9deaa | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 7 | SemanticChunker@1.0.0 | 8752a9f0111586e8169e164fb2bdf76f77ff67667bfa3d511a376b0040fc55c7 | [Step-by-step implementation > Step 1b]
```js
const step1b = word => {
if (word.endsWith('eed') && mGreaterThanZero.test(word.slice(0, -3)))
return word.slice(0, -1);
let matched = null;
if (word.endsWith('ed') && mGreaterThanZero.test(word.slice(0, -2)))
matched = word.slice(0, -2);
if (word.endsWith('ing') &&... | unknown | unknown | [Step-by-step implementation > Step 1b]
```js
const step1b = word => {
if (word.endsWith('eed') && mGreaterThanZero.test(word.slice(0, -3)))
return word.slice(0, -1);
let matched = null;
if (word.endsWith('ed') && mGreaterThanZero.test(word.slice(0, -2)))
matched = word.slice(0, -2);
if (word.endsWith('ing') &&... | [Step-by-step implementation > Step 1b]
```js
const step1b = word => {
if (word.endsWith('eed') && mGreaterThanZero.test(word.slice(0, -3)))
return word.slice(0, -1);
let matched = null;
if (word.endsWith('ed') && mGreaterThanZero.test(word.slice(0, -2)))
matched = word.slice(0, -2);
if (word.endsWith('ing') &&... | code_snippets | ||
febd754e-2935-450a-ba10-59e5a19f52e4 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 8 | SemanticChunker@1.0.0 | 5596198b0cf58644adef8e43d1daf4b445bc49bdf588833c75476feeeddf9a9a | [Step-by-step implementation > Step 1c]
### Step 1c
Step 1c is concerned with the removal of `-y` **suffixes**. The rule is as follows:
| Rule | Example |
|------|---------|
| `(*v*) Y -> I` | `HAPPY -> HAPPI` <br/> `SKY -> SKI` |
```js
const step1c = word => {
if (word.endsWith('y') && stemContainsVowel.test(word... | unknown | unknown | [Step-by-step implementation > Step 1c]
### Step 1c
Step 1c is concerned with the removal of `-y` **suffixes**. The rule is as follows:
| Rule | Example |
|------|---------|
| `(*v*) Y -> I` | `HAPPY -> HAPPI` <br/> `SKY -> SKI` |
```js
const step1c = word => {
if (word.endsWith('y') && stemContainsVowel.test(word... | [Step-by-step implementation > Step 1c]
### Step 1c
Step 1c is concerned with the removal of `-y` **suffixes**. The rule is as follows:
| Rule | Example |
|------|---------|
| `(*v*) Y -> I` | `HAPPY -> HAPPI` <br/> `SKY -> SKI` |
```js
const step1c = word => {
if (word.endsWith('y') && stemContainsVowel.test(word... | code_snippets | ||
ff6ad926-33d0-42c8-a2c8-5f389e6a3cea | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/porter-stemming-algorithm.md | unknown | 3414055b-0f90-4cae-a05b-8a3ecb974adc | 10 | SemanticChunker@1.0.0 | 92b48d4d26b6d6259b3d39d2fb97eebc5db9276c5bf0e5f95f62bbd39c6a239f | [Step-by-step implementation > Step 2]
```js
const step2 = word => {
const rules = {
ational: 'ate',
tional: 'tion',
enci: 'ence',
anci: 'ance',
izer: 'ize',
abli: 'able',
alli: 'al',
entli: 'ent',
eli: 'e',
ousli: 'ous',
ization: 'ize',
ation: 'ate',
ator: 'ate',
alism: 'al',
iveness: 'ive',
fulness:... | unknown | unknown | [Step-by-step implementation > Step 2]
```js
const step2 = word => {
const rules = {
ational: 'ate',
tional: 'tion',
enci: 'ence',
anci: 'ance',
izer: 'ize',
abli: 'able',
alli: 'al',
entli: 'ent',
eli: 'e',
ousli: 'ous',
ization: 'ize',
ation: 'ate',
ator: 'ate',
alism: 'al',
iveness: 'ive',
fulness:... | [Step-by-step implementation > Step 2]
```js
const step2 = word => {
const rules = {
ational: 'ate',
tional: 'tion',
enci: 'ence',
anci: 'ance',
izer: 'ize',
abli: 'able',
alli: 'al',
entli: 'ent',
eli: 'e',
ousli: 'ous',
ization: 'ize',
ation: 'ate',
ator: 'ate',
alism: 'al',
iveness: 'ive',
fulness:... | code_snippets | ||
7d5c73b9-4fa8-410d-9c24-4d6569fbbcb0 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/powerset.md | unknown | f8a0947e-084c-4e35-8327-828db728d556 | 0 | SemanticChunker@1.0.0 | d0fa4c6c49fce0fb955036025ed0c7b6db25404e83c7c7d38eaf85f690e5fe51 | ---
title: Calculate the powerset of a JavaScript array
shortTitle: Powerset of array
language: javascript
tags: [math]
cover: new-plant
excerpt: Generate the powerset of a given array of numbers or other primitive values.
listed: true
dateModified: 2024-03-11
---
The powerset of a set is the **set of all its subsets*... | unknown | unknown | ---
title: Calculate the powerset of a JavaScript array
shortTitle: Powerset of array
language: javascript
tags: [math]
cover: new-plant
excerpt: Generate the powerset of a given array of numbers or other primitive values.
listed: true
dateModified: 2024-03-11
---
The powerset of a set is the **set of all its subsets*... | ---
title: Calculate the powerset of a JavaScript array
shortTitle: Powerset of array
language: javascript
tags: [math]
cover: new-plant
excerpt: Generate the powerset of a given array of numbers or other primitive values.
listed: true
dateModified: 2024-03-11
---
The powerset of a set is the **set of all its subsets*... | code_snippets | ||
ae4a957e-0b3f-4155-b22a-edb892ab2d4d | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/promise-then-finally.md | unknown | fc8893a8-a167-49b9-9614-3162753bc62b | 0 | SemanticChunker@1.0.0 | 2054e38c43c00609714fcfbcd97b9d2704f069b66082ebde84cf1117e7681873 | ---
title: What is the difference between then and finally in a JavaScript promise?
shortTitle: Promise then vs finally
language: javascript
tags: [promises,function]
cover: blue-sunrise
excerpt: A JavaScript promise's `then` and `finally` methods seem very similar. But there are a few important differences you need to... | unknown | unknown | ---
title: What is the difference between then and finally in a JavaScript promise?
shortTitle: Promise then vs finally
language: javascript
tags: [promises,function]
cover: blue-sunrise
excerpt: A JavaScript promise's `then` and `finally` methods seem very similar. But there are a few important differences you need to... | ---
title: What is the difference between then and finally in a JavaScript promise?
shortTitle: Promise then vs finally
language: javascript
tags: [promises,function]
cover: blue-sunrise
excerpt: A JavaScript promise's `then` and `finally` methods seem very similar. But there are a few important differences you need to... | code_snippets | ||
3a2259ec-8ab9-4696-8685-b2491a5a24be | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/promise-then-catch.md | unknown | 6efa76e8-481f-4e1a-b313-19a4531d7960 | 0 | SemanticChunker@1.0.0 | 27d8178950699b876a17d2d32e2b1f693c063a273a9ca6684a0b6d3b50e05c7b | ---
title: The order of then and catch matters
language: javascript
tags: [promises,function]
cover: blue-sunrise
excerpt: Messing up the order of chained `then` and `catch` methods in JavaScript promises can cause problems. Here's a short primer on the subject.
listed: true
dateModified: 2021-06-12
---
Many if not mo... | unknown | unknown | ---
title: The order of then and catch matters
language: javascript
tags: [promises,function]
cover: blue-sunrise
excerpt: Messing up the order of chained `then` and `catch` methods in JavaScript promises can cause problems. Here's a short primer on the subject.
listed: true
dateModified: 2021-06-12
---
Many if not mo... | ---
title: The order of then and catch matters
language: javascript
tags: [promises,function]
cover: blue-sunrise
excerpt: Messing up the order of chained `then` and `catch` methods in JavaScript promises can cause problems. Here's a short primer on the subject.
listed: true
dateModified: 2021-06-12
---
Many if not mo... | code_snippets | ||
07fa3766-1038-41c4-a659-8886c6f7bd6d | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/progressive-enhancement-web-components.md | unknown | 2bc82342-96a9-448e-b6d4-bbda966190d3 | 6 | SemanticChunker@1.0.0 | 04a5c1e80757736372e0a8d1e6570eb12837f6b14e2755eabb95b1b5c2634b83 | [Authoring in Markdown > Non-interactive first]
### Non-interactive first
The last piece of the puzzle was to **optimize for non-interactive scenarios** first. Writing content that can work without the interactive wrapper is good, but sometimes you need to know if the wrapper is interactive or not to style it correct... | unknown | unknown | [Authoring in Markdown > Non-interactive first]
### Non-interactive first
The last piece of the puzzle was to **optimize for non-interactive scenarios** first. Writing content that can work without the interactive wrapper is good, but sometimes you need to know if the wrapper is interactive or not to style it correct... | [Authoring in Markdown > Non-interactive first]
### Non-interactive first
The last piece of the puzzle was to **optimize for non-interactive scenarios** first. Writing content that can work without the interactive wrapper is good, but sometimes you need to know if the wrapper is interactive or not to style it correct... | code_snippets | ||
2518f651-f6bd-482e-be2e-b45437f86c74 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/progressive-enhancement-web-components.md | unknown | 2bc82342-96a9-448e-b6d4-bbda966190d3 | 8 | SemanticChunker@1.0.0 | 49a3c61b5f8d68aca6b0058d7e93a868f295bdc1080dede62a7f302f15f623a2 | [Goals & limitations > Conclusion]
## Conclusion
This is a fairly simple example of how I managed to create a modular, dependency-free, progressive enhancement-friendly setup for my website. I hope it was enlightening about how such problems can be approached and solved, without resorting to overly complex solutions ... | unknown | unknown | [Goals & limitations > Conclusion]
## Conclusion
This is a fairly simple example of how I managed to create a modular, dependency-free, progressive enhancement-friendly setup for my website. I hope it was enlightening about how such problems can be approached and solved, without resorting to overly complex solutions ... | [Goals & limitations > Conclusion]
## Conclusion
This is a fairly simple example of how I managed to create a modular, dependency-free, progressive enhancement-friendly setup for my website. I hope it was enlightening about how such problems can be approached and solved, without resorting to overly complex solutions ... | code_snippets | ||
2fdd8498-b04d-48ce-9fe8-9fe8595df869 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/progressive-enhancement-web-components.md | unknown | 2bc82342-96a9-448e-b6d4-bbda966190d3 | 5 | SemanticChunker@1.0.0 | ce60ad3629915614501ef89b9d0db1f46cf375fc410bb63819cb30874b44d1bc | [Authoring in Markdown > JavaScript modules]
What these two code snippets do is quite simple, really. The first snippet loads the JavaScript module. The magical things about modules is that they are **only executed once**. This means that if you have multiple instances of the same component on the page, the JavaScript... | unknown | unknown | [Authoring in Markdown > JavaScript modules]
What these two code snippets do is quite simple, really. The first snippet loads the JavaScript module. The magical things about modules is that they are **only executed once**. This means that if you have multiple instances of the same component on the page, the JavaScript... | [Authoring in Markdown > JavaScript modules]
What these two code snippets do is quite simple, really. The first snippet loads the JavaScript module. The magical things about modules is that they are **only executed once**. This means that if you have multiple instances of the same component on the page, the JavaScript... | code_snippets | ||
63012b6f-457c-423a-835b-513b1be81e43 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/progressive-enhancement-web-components.md | unknown | 2bc82342-96a9-448e-b6d4-bbda966190d3 | 0 | SemanticChunker@1.0.0 | e28baa8beeedc891ad0919bb1311ca7a9a459bd041a7372aeeddbb3b3a4a6b8a | ---
title: Progressive enhancement with Web Components
shortTitle: Progressive enhancement with Web Components
language: javascript
tags: [browser]
cover: san-francisco-skyline
excerpt: Dive into Web Components with me and learn how I used them to create modular interactive components to progressively enhance my websit... | unknown | unknown | ---
title: Progressive enhancement with Web Components
shortTitle: Progressive enhancement with Web Components
language: javascript
tags: [browser]
cover: san-francisco-skyline
excerpt: Dive into Web Components with me and learn how I used them to create modular interactive components to progressively enhance my websit... | ---
title: Progressive enhancement with Web Components
shortTitle: Progressive enhancement with Web Components
language: javascript
tags: [browser]
cover: san-francisco-skyline
excerpt: Dive into Web Components with me and learn how I used them to create modular interactive components to progressively enhance my websit... | code_snippets | ||
793a5375-a88a-45af-9bd8-8870442fcb2f | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/progressive-enhancement-web-components.md | unknown | 2bc82342-96a9-448e-b6d4-bbda966190d3 | 4 | SemanticChunker@1.0.0 | 7c2417a1f5d7bacdafc4b424a9b309b4c99e7915960d2024d48bc08a65d091a9 | [Authoring in Markdown > JavaScript modules]
### JavaScript modules
<baseline-support featureId="js-modules">
</baseline-support>
Having found a way to author interactive content in Markdown, I now needed a way to actually **make the content interactive** for the user, while maintaining my goals of modularity and av... | unknown | unknown | [Authoring in Markdown > JavaScript modules]
### JavaScript modules
<baseline-support featureId="js-modules">
</baseline-support>
Having found a way to author interactive content in Markdown, I now needed a way to actually **make the content interactive** for the user, while maintaining my goals of modularity and av... | [Authoring in Markdown > JavaScript modules]
### JavaScript modules
<baseline-support featureId="js-modules">
</baseline-support>
Having found a way to author interactive content in Markdown, I now needed a way to actually **make the content interactive** for the user, while maintaining my goals of modularity and av... | code_snippets | ||
9a3a7024-03a0-485d-8084-f95d920a01e4 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/progressive-enhancement-web-components.md | unknown | 2bc82342-96a9-448e-b6d4-bbda966190d3 | 1 | SemanticChunker@1.0.0 | 8ffce10e36574838b1772634fc5c0069e3eb2cf32f0aec1d8e88a3cfb818ec7e | [Goals & limitations > Authoring in Markdown]
### Authoring in Markdown
First and foremost, I like the experience of **writing Markdown in VSCode**, so I didn't want any fancy tools or stacks of components to build something plain and simple. I wanted to sprinkle interactivity as part of my regular authoring process,... | unknown | unknown | [Goals & limitations > Authoring in Markdown]
### Authoring in Markdown
First and foremost, I like the experience of **writing Markdown in VSCode**, so I didn't want any fancy tools or stacks of components to build something plain and simple. I wanted to sprinkle interactivity as part of my regular authoring process,... | [Goals & limitations > Authoring in Markdown]
### Authoring in Markdown
First and foremost, I like the experience of **writing Markdown in VSCode**, so I didn't want any fancy tools or stacks of components to build something plain and simple. I wanted to sprinkle interactivity as part of my regular authoring process,... | code_snippets | ||
c7be8555-b5ea-45fe-81e9-2c7a70cadcc0 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/progressive-enhancement-web-components.md | unknown | 2bc82342-96a9-448e-b6d4-bbda966190d3 | 7 | SemanticChunker@1.0.0 | 6dcde06024f024e578b81c66fec12cc60c365d188e8ce27a2376c6ebdab0af42 | [Authoring in Markdown > Non-interactive first]
Finally, I could select the custom element tag in CSS, just like any other element, and style it by checking for the `interactive` attribute. This would allow me to style the component differently depending on whether it was interactive or not.
```css
interactive-compon... | unknown | unknown | [Authoring in Markdown > Non-interactive first]
Finally, I could select the custom element tag in CSS, just like any other element, and style it by checking for the `interactive` attribute. This would allow me to style the component differently depending on whether it was interactive or not.
```css
interactive-compon... | [Authoring in Markdown > Non-interactive first]
Finally, I could select the custom element tag in CSS, just like any other element, and style it by checking for the `interactive` attribute. This would allow me to style the component differently depending on whether it was interactive or not.
```css
interactive-compon... | code_snippets | ||
cdca1c91-8e8a-466b-b8a8-e77920b1a786 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/progressive-enhancement-web-components.md | unknown | 2bc82342-96a9-448e-b6d4-bbda966190d3 | 2 | SemanticChunker@1.0.0 | e71abb5c4ddeb522cdde3997431230d06cf0a31d7c5d13ff1cbec5c35685ef69 | [Goals & limitations > Authoring in Markdown]
```
### Progressive enhancement
The second and most important goal was to ensure that the content I created would be **accessible to everyone**, everywhere, in every format. This technically meant making sure that content would be supported in the following scenarios:
1... | unknown | unknown | [Goals & limitations > Authoring in Markdown]
```
### Progressive enhancement
The second and most important goal was to ensure that the content I created would be **accessible to everyone**, everywhere, in every format. This technically meant making sure that content would be supported in the following scenarios:
1... | [Goals & limitations > Authoring in Markdown]
```
### Progressive enhancement
The second and most important goal was to ensure that the content I created would be **accessible to everyone**, everywhere, in every format. This technically meant making sure that content would be supported in the following scenarios:
1... | code_snippets | ||
fb9092ac-4aa5-4b5d-b727-ced0dac37161 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/progressive-enhancement-web-components.md | unknown | 2bc82342-96a9-448e-b6d4-bbda966190d3 | 3 | SemanticChunker@1.0.0 | 0076d22f35a420245a37f78874bf8b2ca0de196c9fed86c9cfbb4d659be23822 | [Goals & limitations > Authoring in Markdown]
```html title="GitHub Preview" {3,13}
<p>This is some content I am writing.</p>
<div>
<p>I can write <strong>regular</strong> Markdown in here.</p>
<table>
<thead>
<tr><th>I can also write tables</th></tr>
</thead>
<tbody>
<tr><td>Which are a huge pain to write in ... | unknown | unknown | [Goals & limitations > Authoring in Markdown]
```html title="GitHub Preview" {3,13}
<p>This is some content I am writing.</p>
<div>
<p>I can write <strong>regular</strong> Markdown in here.</p>
<table>
<thead>
<tr><th>I can also write tables</th></tr>
</thead>
<tbody>
<tr><td>Which are a huge pain to write in ... | [Goals & limitations > Authoring in Markdown]
```html title="GitHub Preview" {3,13}
<p>This is some content I am writing.</p>
<div>
<p>I can write <strong>regular</strong> Markdown in here.</p>
<table>
<thead>
<tr><th>I can also write tables</th></tr>
</thead>
<tbody>
<tr><td>Which are a huge pain to write in ... | code_snippets | ||
22fc20f4-3e4e-4a85-9876-fcb9885fa69a | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/proxy-array-negative-index.md | unknown | a5cef341-736e-45d6-869a-5c40f5193ec3 | 0 | SemanticChunker@1.0.0 | ee4bb60b3d686dd01a7db3ed846616e01808009d84179b70fcb0f1e5698e1d54 | ---
title: Negative index in JavaScript array
shortTitle: Negative index array proxy
language: javascript
tags: [proxy,array]
cover: budapest-palace
excerpt: Ever wanted to use negative indices in JavaScript arrays? Here's a simple way to do it using a Proxy.
listed: true
dateModified: 2022-10-02
---
`Array.prototype.... | unknown | unknown | ---
title: Negative index in JavaScript array
shortTitle: Negative index array proxy
language: javascript
tags: [proxy,array]
cover: budapest-palace
excerpt: Ever wanted to use negative indices in JavaScript arrays? Here's a simple way to do it using a Proxy.
listed: true
dateModified: 2022-10-02
---
`Array.prototype.... | ---
title: Negative index in JavaScript array
shortTitle: Negative index array proxy
language: javascript
tags: [proxy,array]
cover: budapest-palace
excerpt: Ever wanted to use negative indices in JavaScript arrays? Here's a simple way to do it using a Proxy.
listed: true
dateModified: 2022-10-02
---
`Array.prototype.... | code_snippets | ||
3a80f402-3fa3-4677-ba6e-43f822551930 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/proxy-array-negative-index.md | unknown | a5cef341-736e-45d6-869a-5c40f5193ec3 | 1 | SemanticChunker@1.0.0 | 38ce28b6389a85e4d8a354c6000b9d8183f7ec9a1d0dc4748b0ca4188c700f14 | > [!IMPORTANT]
>
> <baseline-support featureId="array-at">
> </baseline-support>
>
> As of May, 2025, `Array.prototype.at()` is **widely available in all modern browsers and Node.js**. You should probably consider using it, if possible, as it provides a more straightforward and performant interface for accessing elemen... | unknown | unknown | > [!IMPORTANT]
>
> <baseline-support featureId="array-at">
> </baseline-support>
>
> As of May, 2025, `Array.prototype.at()` is **widely available in all modern browsers and Node.js**. You should probably consider using it, if possible, as it provides a more straightforward and performant interface for accessing elemen... | > [!IMPORTANT]
>
> <baseline-support featureId="array-at">
> </baseline-support>
>
> As of May, 2025, `Array.prototype.at()` is **widely available in all modern browsers and Node.js**. You should probably consider using it, if possible, as it provides a more straightforward and performant interface for accessing elemen... | code_snippets | ||
91dddb89-c773-4b4f-9011-0d9597b99d1f | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/proxy-introduction.md | unknown | 37eeeb49-b6e7-4065-83c4-033d139f2af6 | 1 | SemanticChunker@1.0.0 | d040f1a30c49881810ddd4dc71a30465fa9b1d54dc57c1971c58fa8c6464a393 | - `get(target, prop, receiver)` - Intercepts calls to `target[prop]`.
- `set(target, prop, value, receiver)` - Intercepts calls to `target[prop] = value`.
- `has(target, prop)` - Intercepts calls to `prop in target`.
- `apply(target, thisArg, argumentsList)` - Intercepts calls to functions.
- `construct(target, argumen... | unknown | unknown | - `get(target, prop, receiver)` - Intercepts calls to `target[prop]`.
- `set(target, prop, value, receiver)` - Intercepts calls to `target[prop] = value`.
- `has(target, prop)` - Intercepts calls to `prop in target`.
- `apply(target, thisArg, argumentsList)` - Intercepts calls to functions.
- `construct(target, argumen... | - `get(target, prop, receiver)` - Intercepts calls to `target[prop]`.
- `set(target, prop, value, receiver)` - Intercepts calls to `target[prop] = value`.
- `has(target, prop)` - Intercepts calls to `prop in target`.
- `apply(target, thisArg, argumentsList)` - Intercepts calls to functions.
- `construct(target, argumen... | code_snippets | ||
df9fd43b-8dfd-425f-a38d-7e679e113dbd | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/proxy-introduction.md | unknown | 37eeeb49-b6e7-4065-83c4-033d139f2af6 | 0 | SemanticChunker@1.0.0 | b7688fbd2ed143d8c30f7908b4abdd80c2e9c482f03ec5e0dc557b65fcf362f7 | ---
title: An Introduction to JavaScript Proxy
shortTitle: JavaScript Proxy Introduction
language: javascript
tags: [proxy,pattern]
cover: red-mountain-range
excerpt: A quick introduction to the JavaScript Proxy object and where it can be used.
listed: true
dateModified: 2023-04-02
---
The JavaScript `Proxy` object is... | unknown | unknown | ---
title: An Introduction to JavaScript Proxy
shortTitle: JavaScript Proxy Introduction
language: javascript
tags: [proxy,pattern]
cover: red-mountain-range
excerpt: A quick introduction to the JavaScript Proxy object and where it can be used.
listed: true
dateModified: 2023-04-02
---
The JavaScript `Proxy` object is... | ---
title: An Introduction to JavaScript Proxy
shortTitle: JavaScript Proxy Introduction
language: javascript
tags: [proxy,pattern]
cover: red-mountain-range
excerpt: A quick introduction to the JavaScript Proxy object and where it can be used.
listed: true
dateModified: 2023-04-02
---
The JavaScript `Proxy` object is... | code_snippets | ||
2731cb47-e579-49f2-8fac-a51264f5ce62 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/property-enumerability.md | unknown | cdb78d3b-c1cb-4a52-8e04-dc705868d742 | 0 | SemanticChunker@1.0.0 | 2e5d9269a0f042177c0b4eade5f7bf31bc66e14a465b50c0b105ccb1e79f20ac | ---
title: JavaScript property enumerability
shortTitle: Property enumerability
language: javascript
tags: [object]
cover: old-consoles
excerpt: Property enumerability dictates how JavaScript object properties behave in different scenarios.
listed: true
dateModified: 2022-09-11
---
In most cases, object properties are... | unknown | unknown | ---
title: JavaScript property enumerability
shortTitle: Property enumerability
language: javascript
tags: [object]
cover: old-consoles
excerpt: Property enumerability dictates how JavaScript object properties behave in different scenarios.
listed: true
dateModified: 2022-09-11
---
In most cases, object properties are... | ---
title: JavaScript property enumerability
shortTitle: Property enumerability
language: javascript
tags: [object]
cover: old-consoles
excerpt: Property enumerability dictates how JavaScript object properties behave in different scenarios.
listed: true
dateModified: 2022-09-11
---
In most cases, object properties are... | code_snippets | ||
5b99a601-e1ce-4061-8bd8-02d7ce71006b | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/promisify.md | unknown | d5ab2446-607c-461f-ba3f-475e7554c7ee | 0 | SemanticChunker@1.0.0 | 4f8244131392a1ecf73a6f823fe2fc08e4f56442affcacbd89fb8a41fbd6d315 | ---
title: Make a JavaScript function return a promise
shortTitle: Promisify function
language: javascript
tags: [function,promises]
cover: nature-screen
excerpt: Learn how to convert an asynchronous function to return a promise in JavaScript.
listed: true
dateModified: 2024-07-29
---
Have you ever wanted to convert a... | unknown | unknown | ---
title: Make a JavaScript function return a promise
shortTitle: Promisify function
language: javascript
tags: [function,promises]
cover: nature-screen
excerpt: Learn how to convert an asynchronous function to return a promise in JavaScript.
listed: true
dateModified: 2024-07-29
---
Have you ever wanted to convert a... | ---
title: Make a JavaScript function return a promise
shortTitle: Promisify function
language: javascript
tags: [function,promises]
cover: nature-screen
excerpt: Learn how to convert an asynchronous function to return a promise in JavaScript.
listed: true
dateModified: 2024-07-29
---
Have you ever wanted to convert a... | code_snippets | ||
a99f9118-e685-41a2-b31a-f5660170bc48 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/primitive-instanceof.md | unknown | 59af735e-d2c1-4df9-837e-4fa46cf681fb | 1 | SemanticChunker@1.0.0 | a130cd3f7696ea7b695c298122c00ba19d0003c5fb999b75a4aa8384bb013eeb | ```js
class PrimitiveNumber {
static [Symbol.hasInstance] = x => typeof x === 'number';
}
123 instanceof PrimitiveNumber; // true
class PrimitiveString {
static [Symbol.hasInstance] = x => typeof x === 'string';
}
'abc' instanceof PrimitiveString; // true
class PrimitiveBoolean {
static [Symbol.hasInstance] = x =>... | unknown | unknown | ```js
class PrimitiveNumber {
static [Symbol.hasInstance] = x => typeof x === 'number';
}
123 instanceof PrimitiveNumber; // true
class PrimitiveString {
static [Symbol.hasInstance] = x => typeof x === 'string';
}
'abc' instanceof PrimitiveString; // true
class PrimitiveBoolean {
static [Symbol.hasInstance] = x =>... | ```js
class PrimitiveNumber {
static [Symbol.hasInstance] = x => typeof x === 'number';
}
123 instanceof PrimitiveNumber; // true
class PrimitiveString {
static [Symbol.hasInstance] = x => typeof x === 'string';
}
'abc' instanceof PrimitiveString; // true
class PrimitiveBoolean {
static [Symbol.hasInstance] = x =>... | code_snippets | ||
af51857e-49f5-4b45-91f9-be0e6a6de307 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/primitive-instanceof.md | unknown | 59af735e-d2c1-4df9-837e-4fa46cf681fb | 0 | SemanticChunker@1.0.0 | aa3074550adf1e12cb3a17067e108b88fca4c29e5f991d078f2a98f32abd009b | ---
title: Is there a way to use instanceof for primitive JavaScript values?
shortTitle: Using instanceof for primitive values
language: javascript
tags: [type]
cover: wooden-bowl
excerpt: JavaScript's `instanceof` operator can't be used with primitive values, but there are a some tricks that you can leverage to your a... | unknown | unknown | ---
title: Is there a way to use instanceof for primitive JavaScript values?
shortTitle: Using instanceof for primitive values
language: javascript
tags: [type]
cover: wooden-bowl
excerpt: JavaScript's `instanceof` operator can't be used with primitive values, but there are a some tricks that you can leverage to your a... | ---
title: Is there a way to use instanceof for primitive JavaScript values?
shortTitle: Using instanceof for primitive values
language: javascript
tags: [type]
cover: wooden-bowl
excerpt: JavaScript's `instanceof` operator can't be used with primitive values, but there are a some tricks that you can leverage to your a... | code_snippets | ||
3b7bda44-a4b2-48ab-a3ae-1625d498dfc7 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/pure-functions.md | unknown | 73455160-e089-4e66-8a9e-cb7c9654b6c7 | 0 | SemanticChunker@1.0.0 | c7e990d122414dfda55f6c2d18f0fa3691d4f805135e259448b12601d2cf7fdd | ---
title: What is a pure function?
shortTitle: Pure function introduction
language: javascript
tags: [function]
cover: dark-leaves
excerpt: Pure functions are a very important concept to know, especially if you're interested in functional programming.
listed: true
dateModified: 2021-12-19
journeyId: js/functional-prog... | unknown | unknown | ---
title: What is a pure function?
shortTitle: Pure function introduction
language: javascript
tags: [function]
cover: dark-leaves
excerpt: Pure functions are a very important concept to know, especially if you're interested in functional programming.
listed: true
dateModified: 2021-12-19
journeyId: js/functional-prog... | ---
title: What is a pure function?
shortTitle: Pure function introduction
language: javascript
tags: [function]
cover: dark-leaves
excerpt: Pure functions are a very important concept to know, especially if you're interested in functional programming.
listed: true
dateModified: 2021-12-19
journeyId: js/functional-prog... | code_snippets | ||
d5c7f334-660b-438d-bcde-50594831d4f9 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/promises.md | unknown | 1502794f-dc31-4b4b-be73-ef19745b5fd0 | 0 | SemanticChunker@1.0.0 | 63451e25fdc29bbc30ede40acaa6350aea5006c3d804f4a6e294286f9a547b92 | ---
title: What are promises in JavaScript? In which states can a promise be?
shortTitle: Promises introduction
language: javascript
tags: [promises,function]
cover: sail-away
excerpt: JavaScript's promises represent the eventual completion (or failure) of asynchronous operations and their resulting value.
listed: true... | unknown | unknown | ---
title: What are promises in JavaScript? In which states can a promise be?
shortTitle: Promises introduction
language: javascript
tags: [promises,function]
cover: sail-away
excerpt: JavaScript's promises represent the eventual completion (or failure) of asynchronous operations and their resulting value.
listed: true... | ---
title: What are promises in JavaScript? In which states can a promise be?
shortTitle: Promises introduction
language: javascript
tags: [promises,function]
cover: sail-away
excerpt: JavaScript's promises represent the eventual completion (or failure) of asynchronous operations and their resulting value.
listed: true... | code_snippets | ||
b9c67027-42ad-4bc4-9c3a-9f861270ec44 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/random-alphanumeric.md | unknown | 53611452-733c-42be-be42-570c5491a96a | 0 | SemanticChunker@1.0.0 | caead032196fe8dcbf1f5ee97f4963a6d0281e56a3f1c07a2a8e39b9bce5cf34 | ---
title: Generate a random alphanumeric JavaScript string
shortTitle: Random alphanumeric
language: javascript
tags: [string,random]
cover: gold-typewriter
excerpt: Use JavaScript to generate a random alphanumeric string of a specified length.
listed: true
dateModified: 2024-03-15
---
While generating a [random arit... | unknown | unknown | ---
title: Generate a random alphanumeric JavaScript string
shortTitle: Random alphanumeric
language: javascript
tags: [string,random]
cover: gold-typewriter
excerpt: Use JavaScript to generate a random alphanumeric string of a specified length.
listed: true
dateModified: 2024-03-15
---
While generating a [random arit... | ---
title: Generate a random alphanumeric JavaScript string
shortTitle: Random alphanumeric
language: javascript
tags: [string,random]
cover: gold-typewriter
excerpt: Use JavaScript to generate a random alphanumeric string of a specified length.
listed: true
dateModified: 2024-03-15
---
While generating a [random arit... | code_snippets | ||
15ee45ec-205b-4e27-a7f4-f543e7b5eb76 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/range-generator.md | unknown | f939d44d-b937-4d0d-9701-a4f295144a14 | 1 | SemanticChunker@1.0.0 | 5133f7b336fc940caa44a0a83026d969fa751194a3780af16f74b940fcea1c6a | [A simple range generator]
## A simple range generator
As the control flow of generators is tricky to grasp at first, let's start with the **simplest possible range implementation**. We'll only account for an `end` value, starting at `0` and incrementing by `1`. What we need to do to accomplish this is to use a `for`... | unknown | unknown | [A simple range generator]
## A simple range generator
As the control flow of generators is tricky to grasp at first, let's start with the **simplest possible range implementation**. We'll only account for an `end` value, starting at `0` and incrementing by `1`. What we need to do to accomplish this is to use a `for`... | [A simple range generator]
## A simple range generator
As the control flow of generators is tricky to grasp at first, let's start with the **simplest possible range implementation**. We'll only account for an `end` value, starting at `0` and incrementing by `1`. What we need to do to accomplish this is to use a `for`... | code_snippets | ||
3724829d-7503-429c-8d0c-62c63a9bab69 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/range-generator.md | unknown | f939d44d-b937-4d0d-9701-a4f295144a14 | 6 | SemanticChunker@1.0.0 | 280a1f902fa1546a0f007ed068f861afeb8f58a859b614e18eea51b16d1cb14c | [A simple range generator > Adding start and step parameters]
## Adding start and step parameters
Having implemented the most basic version of a range generator, we can now extend it to accept `start` and `step` parameters. This will allow us to define a range that starts at a specific value and increments by a speci... | unknown | unknown | [A simple range generator > Adding start and step parameters]
## Adding start and step parameters
Having implemented the most basic version of a range generator, we can now extend it to accept `start` and `step` parameters. This will allow us to define a range that starts at a specific value and increments by a speci... | [A simple range generator > Adding start and step parameters]
## Adding start and step parameters
Having implemented the most basic version of a range generator, we can now extend it to accept `start` and `step` parameters. This will allow us to define a range that starts at a specific value and increments by a speci... | code_snippets | ||
72ac6f43-ce2c-47cb-830e-30d51e17aa8d | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/range-generator.md | unknown | f939d44d-b937-4d0d-9701-a4f295144a14 | 2 | SemanticChunker@1.0.0 | 9ece79e7a5cc788dd2d2ff8131eab8cb98a05099a4ac48aa33b0e0c6bd0c5f1d | [A simple range generator > Consuming the generator output]
## Consuming the generator output
Consuming the output of a generator can be done **step-by-step**, as needed, or **all at once**. Depending on our needs we have a few available options. | unknown | unknown | [A simple range generator > Consuming the generator output]
## Consuming the generator output
Consuming the output of a generator can be done **step-by-step**, as needed, or **all at once**. Depending on our needs we have a few available options. | [A simple range generator > Consuming the generator output]
## Consuming the generator output
Consuming the output of a generator can be done **step-by-step**, as needed, or **all at once**. Depending on our needs we have a few available options. | code_snippets | ||
9fea6837-02cd-4477-9c57-ad4f407256b3 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/range-generator.md | unknown | f939d44d-b937-4d0d-9701-a4f295144a14 | 3 | SemanticChunker@1.0.0 | 8d12ab9c37caeeebc6cb954366a83e45d34b5b3afd6568467e6d054fc9f6802b | [Consuming the generator output > Consumption as needed]
### Consumption as needed
We can, for example, use the [generator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator) to call `Generator.prototype.next()` until it returns `{ value: undefined, done: true }` to ite... | unknown | unknown | [Consuming the generator output > Consumption as needed]
### Consumption as needed
We can, for example, use the [generator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator) to call `Generator.prototype.next()` until it returns `{ value: undefined, done: true }` to ite... | [Consuming the generator output > Consumption as needed]
### Consumption as needed
We can, for example, use the [generator object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator) to call `Generator.prototype.next()` until it returns `{ value: undefined, done: true }` to ite... | code_snippets | ||
cc2fd875-a253-4082-92b2-460ad945a685 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/range-generator.md | unknown | f939d44d-b937-4d0d-9701-a4f295144a14 | 0 | SemanticChunker@1.0.0 | faa3c9cc2b77b7c537855d9edd52da28bd7480ed7f1a33f328fbbe3201fbf636 | ---
title: Numeric range generator in JavaScript
shortTitle: Range generator
language: javascript
tags: [function,array]
cover: generator
excerpt: Learn how to use JavaScript ES6 generators to create a range generator that produces a sequence of numbers.
listed: true
dateModified: 2024-07-30
---
[JavaScript ES6 genera... | unknown | unknown | ---
title: Numeric range generator in JavaScript
shortTitle: Range generator
language: javascript
tags: [function,array]
cover: generator
excerpt: Learn how to use JavaScript ES6 generators to create a range generator that produces a sequence of numbers.
listed: true
dateModified: 2024-07-30
---
[JavaScript ES6 genera... | ---
title: Numeric range generator in JavaScript
shortTitle: Range generator
language: javascript
tags: [function,array]
cover: generator
excerpt: Learn how to use JavaScript ES6 generators to create a range generator that produces a sequence of numbers.
listed: true
dateModified: 2024-07-30
---
[JavaScript ES6 genera... | code_snippets | ||
ceee8fad-2a3f-4293-ae09-4c52794abd8a | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/range-generator.md | unknown | f939d44d-b937-4d0d-9701-a4f295144a14 | 5 | SemanticChunker@1.0.0 | f3db890365b89bc57912436af94e5874bc19e0ac0487ac7340e6d5c4b1fa8426 | [Consuming the generator output > Generator output as an array]
### Generator output as an array
Finally, we can also use the spread operator (`...`) to consume the generator's output all at once. This is especially useful when you want to [convert the generator's output into an array](/js/s/generator-to-array).
```... | unknown | unknown | [Consuming the generator output > Generator output as an array]
### Generator output as an array
Finally, we can also use the spread operator (`...`) to consume the generator's output all at once. This is especially useful when you want to [convert the generator's output into an array](/js/s/generator-to-array).
```... | [Consuming the generator output > Generator output as an array]
### Generator output as an array
Finally, we can also use the spread operator (`...`) to consume the generator's output all at once. This is especially useful when you want to [convert the generator's output into an array](/js/s/generator-to-array).
```... | code_snippets | ||
eb67a912-eb4e-4737-968e-8cdb53ebbe50 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/range-generator.md | unknown | f939d44d-b937-4d0d-9701-a4f295144a14 | 4 | SemanticChunker@1.0.0 | 6d70ba55c40a7c0da84bdf9ec0c1a9c2c858063d0778889e2ca7291585f5bb8b | [Consuming the generator output > Iterating over the output]
### Iterating over the output
As shown in the previous example, we can also use `for...of` to **iterate over the generator's output**. This is due to the fact that generators are iterable objects, implementing [`Symbol.iterator`](https://developer.mozilla.o... | unknown | unknown | [Consuming the generator output > Iterating over the output]
### Iterating over the output
As shown in the previous example, we can also use `for...of` to **iterate over the generator's output**. This is due to the fact that generators are iterable objects, implementing [`Symbol.iterator`](https://developer.mozilla.o... | [Consuming the generator output > Iterating over the output]
### Iterating over the output
As shown in the previous example, we can also use `for...of` to **iterate over the generator's output**. This is due to the fact that generators are iterable objects, implementing [`Symbol.iterator`](https://developer.mozilla.o... | code_snippets | ||
1c10898a-b6fc-4456-837a-d6094ff00bd0 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/random-boolean.md | unknown | ed2ff54b-dd06-4ac4-866c-7319002b3725 | 0 | SemanticChunker@1.0.0 | 4762d2e33666615b15addb8008fa926021d349088d0adeed8e3a4ffc3e239ab2 | ---
title: Generate a random boolean value in JavaScript
shortTitle: Random boolean
language: javascript
tags: [math,random]
cover: malibu
excerpt: A quick, one-liner to generate a random boolean value in JavaScript.
listed: true
dateModified: 2024-03-14
---
JavaScript doesn't have a built-in function to generate a ra... | unknown | unknown | ---
title: Generate a random boolean value in JavaScript
shortTitle: Random boolean
language: javascript
tags: [math,random]
cover: malibu
excerpt: A quick, one-liner to generate a random boolean value in JavaScript.
listed: true
dateModified: 2024-03-14
---
JavaScript doesn't have a built-in function to generate a ra... | ---
title: Generate a random boolean value in JavaScript
shortTitle: Random boolean
language: javascript
tags: [math,random]
cover: malibu
excerpt: A quick, one-liner to generate a random boolean value in JavaScript.
listed: true
dateModified: 2024-03-14
---
JavaScript doesn't have a built-in function to generate a ra... | code_snippets | ||
1a9b3eba-020a-4606-b53e-a213320166c0 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/random-value-pure-functions.md | unknown | 280202dd-4444-47fb-ab46-b92545c21b84 | 0 | SemanticChunker@1.0.0 | 4d31ede50dc939080509712fe099543ae67b19bd6c000f5f10b11f9dc80a1406 | ---
title: Using random values with pure functions
shortTitle: Pure functions & randomness
language: javascript
tags: [function,random,testing]
cover: do-more-computer
excerpt: Randomness and pure functions don't seem to go hand in hand. But where there's a will, there's a way.
listed: true
dateModified: 2022-06-19
---... | unknown | unknown | ---
title: Using random values with pure functions
shortTitle: Pure functions & randomness
language: javascript
tags: [function,random,testing]
cover: do-more-computer
excerpt: Randomness and pure functions don't seem to go hand in hand. But where there's a will, there's a way.
listed: true
dateModified: 2022-06-19
---... | ---
title: Using random values with pure functions
shortTitle: Pure functions & randomness
language: javascript
tags: [function,random,testing]
cover: do-more-computer
excerpt: Randomness and pure functions don't seem to go hand in hand. But where there's a will, there's a way.
listed: true
dateModified: 2022-06-19
---... | code_snippets | ||
d506c703-baa2-41db-b566-519abc166d23 | unknown | file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/random-value-pure-functions.md | unknown | 280202dd-4444-47fb-ab46-b92545c21b84 | 1 | SemanticChunker@1.0.0 | 2ccac5b25590a3b59564707605863980bc5f38ef169dee116c31ea42f9a13869 | ```js
// A pure function that returns a random value
const getNumber = (min = 0, max = 1, num = Math.random()) =>
Math.max(Math.min(num, max), min);
```
By making this simple change, you can avoid a lot of headaches for you and your team. Using a function such as `Math.random()` as the default argument will require m... | unknown | unknown | ```js
// A pure function that returns a random value
const getNumber = (min = 0, max = 1, num = Math.random()) =>
Math.max(Math.min(num, max), min);
```
By making this simple change, you can avoid a lot of headaches for you and your team. Using a function such as `Math.random()` as the default argument will require m... | ```js
// A pure function that returns a random value
const getNumber = (min = 0, max = 1, num = Math.random()) =>
Math.max(Math.min(num, max), min);
```
By making this simple change, you can avoid a lot of headaches for you and your team. Using a function such as `Math.random()` as the default argument will require m... | code_snippets |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.