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
82b9ee7b-4efb-43fb-a697-330e9847e5b6
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/math-expression-tokenizer.md
unknown
2b648894-b6f9-4ec0-b337-cd2bed3a53c3
2
SemanticChunker@1.0.0
606c4c041c014fa4c4722644de929f6167e14225a0092c594d3681d85140a2aa
[Introduction > Integers and operators] ## Integers and operators At its most basic form, a tokenizer reads an **input** (in this case a string) **one character at a time** and **groups them into tokens**. We'll start as simple as possible, implementing the tokenization of integers and operators. ```js const TOKEN_T...
unknown
unknown
[Introduction > Integers and operators] ## Integers and operators At its most basic form, a tokenizer reads an **input** (in this case a string) **one character at a time** and **groups them into tokens**. We'll start as simple as possible, implementing the tokenization of integers and operators. ```js const TOKEN_T...
[Introduction > Integers and operators] ## Integers and operators At its most basic form, a tokenizer reads an **input** (in this case a string) **one character at a time** and **groups them into tokens**. We'll start as simple as possible, implementing the tokenization of integers and operators. ```js const TOKEN_T...
code_snippets
900099a7-f822-4724-a778-a19e28da59c2
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/math-expression-tokenizer.md
unknown
2b648894-b6f9-4ec0-b337-cd2bed3a53c3
5
SemanticChunker@1.0.0
3a939b1ef7da9cb8889b7ab308359d9d3ed8b88a0a8665304975b0e434f4da9d
[Introduction > Parentheses] ## Parentheses The next step is to add support for parentheses. We'll treat them as separate tokens, as they're used to group expressions. We'll not be adding any **validation** for now, but you can read more about this problem in the [article about bracket pair matching](/js/s/find-match...
unknown
unknown
[Introduction > Parentheses] ## Parentheses The next step is to add support for parentheses. We'll treat them as separate tokens, as they're used to group expressions. We'll not be adding any **validation** for now, but you can read more about this problem in the [article about bracket pair matching](/js/s/find-match...
[Introduction > Parentheses] ## Parentheses The next step is to add support for parentheses. We'll treat them as separate tokens, as they're used to group expressions. We'll not be adding any **validation** for now, but you can read more about this problem in the [article about bracket pair matching](/js/s/find-match...
code_snippets
982c0006-de0f-41cd-aee1-3f624db7e3e6
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/math-expression-tokenizer.md
unknown
2b648894-b6f9-4ec0-b337-cd2bed3a53c3
9
SemanticChunker@1.0.0
21bb8e6260ab844fa6e2d8a031634fdd555567303c5bbb77a1466f3efe8d53c1
[Introduction > Negative numbers] ```js // [continued: part 1] const tokenize = expression => { const tokens = []; let buffer = ''; // Flush the buffer, if it contains a valid number token const flushBuffer = () => { if (!buffer.length) return; const bufferValue = Number.parseFloat(buffer); if (Number.isNaN(b...
unknown
unknown
[Introduction > Negative numbers] ```js // [continued: part 1] const tokenize = expression => { const tokens = []; let buffer = ''; // Flush the buffer, if it contains a valid number token const flushBuffer = () => { if (!buffer.length) return; const bufferValue = Number.parseFloat(buffer); if (Number.isNaN(b...
[Introduction > Negative numbers] ```js // [continued: part 1] const tokenize = expression => { const tokens = []; let buffer = ''; // Flush the buffer, if it contains a valid number token const flushBuffer = () => { if (!buffer.length) return; const bufferValue = Number.parseFloat(buffer); if (Number.isNaN(b...
code_snippets
a4874ace-ec0c-4abd-8dd5-0b446f1af245
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/math-expression-tokenizer.md
unknown
2b648894-b6f9-4ec0-b337-cd2bed3a53c3
6
SemanticChunker@1.0.0
33ed7b8ffa0dda88ae98318e251b77bcefefd1bdcdc4f9a2154d7863ae94b3a4
[Introduction > Parentheses] ```js const TOKEN_TYPES = { NUMBER: 'NUMBER', OPERATOR: { '+': 'OP_ADD', '-': 'OP_SUBTRACT', '*': 'OP_MULTIPLY', '/': 'OP_DIVIDE', }, PARENTHESIS: { '(': 'PAREN_OPEN', ')': 'PAREN_CLOSE', } }; const OPERATORS = Object.keys(TOKEN_TYPES.OPERATOR); const PARENTHESES = Object.keys(...
unknown
unknown
[Introduction > Parentheses] ```js const TOKEN_TYPES = { NUMBER: 'NUMBER', OPERATOR: { '+': 'OP_ADD', '-': 'OP_SUBTRACT', '*': 'OP_MULTIPLY', '/': 'OP_DIVIDE', }, PARENTHESIS: { '(': 'PAREN_OPEN', ')': 'PAREN_CLOSE', } }; const OPERATORS = Object.keys(TOKEN_TYPES.OPERATOR); const PARENTHESES = Object.keys(...
[Introduction > Parentheses] ```js const TOKEN_TYPES = { NUMBER: 'NUMBER', OPERATOR: { '+': 'OP_ADD', '-': 'OP_SUBTRACT', '*': 'OP_MULTIPLY', '/': 'OP_DIVIDE', }, PARENTHESIS: { '(': 'PAREN_OPEN', ')': 'PAREN_CLOSE', } }; const OPERATORS = Object.keys(TOKEN_TYPES.OPERATOR); const PARENTHESES = Object.keys(...
code_snippets
b3d7988d-0354-473c-afd9-3ff5ba6610aa
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/math-expression-tokenizer.md
unknown
2b648894-b6f9-4ec0-b337-cd2bed3a53c3
1
SemanticChunker@1.0.0
54dfe10743de5d7f80486be40631321c619df08490fa3fa6e750ec5988ef9b26
[Introduction] ## Introduction In the context of a math expression, a **token** is a **single unit of the expression**. It can be a number, an operator, a parenthesis, or any other symbol that makes up the expression. For example, in the expression `3 + 4`, the tokens are `3`, `+`, and `4`. **Tokens can span multiple...
unknown
unknown
[Introduction] ## Introduction In the context of a math expression, a **token** is a **single unit of the expression**. It can be a number, an operator, a parenthesis, or any other symbol that makes up the expression. For example, in the expression `3 + 4`, the tokens are `3`, `+`, and `4`. **Tokens can span multiple...
[Introduction] ## Introduction In the context of a math expression, a **token** is a **single unit of the expression**. It can be a number, an operator, a parenthesis, or any other symbol that makes up the expression. For example, in the expression `3 + 4`, the tokens are `3`, `+`, and `4`. **Tokens can span multiple...
code_snippets
b6e0f7fc-4fac-4958-832c-20c0e03dcd87
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/math-expression-tokenizer.md
unknown
2b648894-b6f9-4ec0-b337-cd2bed3a53c3
7
SemanticChunker@1.0.0
b4cf2b3999d59ac658eb626c52b4c982d4d882c65eba08a34a5e140b9f748b4d
[Introduction > Parentheses] Now, our tokenizer correctly handles parentheses, but won't validate if they're paired. ```js tokenize('(3 + 4) * 5'); // [ // { type: 'PAREN_OPEN' }, // { type: 'NUMBER', value: 3 }, // { type: 'OP_ADD' }, // { type: 'NUMBER', value: 4 }, // { type: 'PAREN_CLOSE' }, // { type: 'OP_MULTIP...
unknown
unknown
[Introduction > Parentheses] Now, our tokenizer correctly handles parentheses, but won't validate if they're paired. ```js tokenize('(3 + 4) * 5'); // [ // { type: 'PAREN_OPEN' }, // { type: 'NUMBER', value: 3 }, // { type: 'OP_ADD' }, // { type: 'NUMBER', value: 4 }, // { type: 'PAREN_CLOSE' }, // { type: 'OP_MULTIP...
[Introduction > Parentheses] Now, our tokenizer correctly handles parentheses, but won't validate if they're paired. ```js tokenize('(3 + 4) * 5'); // [ // { type: 'PAREN_OPEN' }, // { type: 'NUMBER', value: 3 }, // { type: 'OP_ADD' }, // { type: 'NUMBER', value: 4 }, // { type: 'PAREN_CLOSE' }, // { type: 'OP_MULTIP...
code_snippets
c5f2dddb-634d-4a1b-a385-06d9e2125aa8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/math-expression-tokenizer.md
unknown
2b648894-b6f9-4ec0-b337-cd2bed3a53c3
10
SemanticChunker@1.0.0
48ea186828b0bf129f79846f9f0f7c13e523d4cea523c397dc10d3faee8cf266
[Introduction > Negative numbers] Notice that the check for the negative sign may result in the `lastToken` indicating it's **not a negative sign** and continue to the operator check. This is intentional, so that both cases can be handled without problems. While the logic for the negative numbers may seem a little co...
unknown
unknown
[Introduction > Negative numbers] Notice that the check for the negative sign may result in the `lastToken` indicating it's **not a negative sign** and continue to the operator check. This is intentional, so that both cases can be handled without problems. While the logic for the negative numbers may seem a little co...
[Introduction > Negative numbers] Notice that the check for the negative sign may result in the `lastToken` indicating it's **not a negative sign** and continue to the operator check. This is intentional, so that both cases can be handled without problems. While the logic for the negative numbers may seem a little co...
code_snippets
dadb1411-8080-4e97-b28c-45fa04351d7e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/math-expression-tokenizer.md
unknown
2b648894-b6f9-4ec0-b337-cd2bed3a53c3
8
SemanticChunker@1.0.0
0841a845e829c89bb3c0c66906183921db31437b2aa3e0ee78196f0f12e57245
[Introduction > Negative numbers] ## Negative numbers Up until this point, we've only been handling positive numbers. To support negative numbers, we need to **differentiate between a subtraction operator and a negative sign**. We'll do this by checking if the `-` character is preceded by an operator, a parenthesis, ...
unknown
unknown
[Introduction > Negative numbers] ## Negative numbers Up until this point, we've only been handling positive numbers. To support negative numbers, we need to **differentiate between a subtraction operator and a negative sign**. We'll do this by checking if the `-` character is preceded by an operator, a parenthesis, ...
[Introduction > Negative numbers] ## Negative numbers Up until this point, we've only been handling positive numbers. To support negative numbers, we need to **differentiate between a subtraction operator and a negative sign**. We'll do this by checking if the `-` character is preceded by an operator, a parenthesis, ...
code_snippets
dc91e54d-be05-4527-bf4d-bbb2a0dcecbf
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/math-expression-tokenizer.md
unknown
2b648894-b6f9-4ec0-b337-cd2bed3a53c3
3
SemanticChunker@1.0.0
c6757b28b3222d4a332c6f5a4f5fc268c355e9ff35e9c12bf42c8b55c4cdfda7
[Introduction > Floating point numbers] ## Floating point numbers Our current implementation will throw an error if there's even a single **unknown character**. The `.` character, used for floating point numbers, will trigger this error, too. ```js tokenize('3.14 + 4'); // Error: Invalid character: . ``` Thus, in o...
unknown
unknown
[Introduction > Floating point numbers] ## Floating point numbers Our current implementation will throw an error if there's even a single **unknown character**. The `.` character, used for floating point numbers, will trigger this error, too. ```js tokenize('3.14 + 4'); // Error: Invalid character: . ``` Thus, in o...
[Introduction > Floating point numbers] ## Floating point numbers Our current implementation will throw an error if there's even a single **unknown character**. The `.` character, used for floating point numbers, will trigger this error, too. ```js tokenize('3.14 + 4'); // Error: Invalid character: . ``` Thus, in o...
code_snippets
39d65ba3-3382-45ef-a04c-0d1c464b371e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/midpoint.md
unknown
1303ce41-e85e-42e9-bd6d-e9e4ea8b20ad
2
SemanticChunker@1.0.0
eefb4603d2aaadddc1d7714274dd54f1c3d40aa9a828b64f3bcf61f5678c3ec0
[Midpoint in 2D space > Midpoint in 3D space] ## Midpoint in 3D space This operation can be easily to extended to **3D space** by adding a third dimension to the input arrays and the output array. ```js const midpoint3D = ([x1, y1, z1], [x2, y2, z2]) => [ (x1 + x2) / 2, (y1 + y2) / 2, (z1 + z2) / 2, ]; midpoint3...
unknown
unknown
[Midpoint in 2D space > Midpoint in 3D space] ## Midpoint in 3D space This operation can be easily to extended to **3D space** by adding a third dimension to the input arrays and the output array. ```js const midpoint3D = ([x1, y1, z1], [x2, y2, z2]) => [ (x1 + x2) / 2, (y1 + y2) / 2, (z1 + z2) / 2, ]; midpoint3...
[Midpoint in 2D space > Midpoint in 3D space] ## Midpoint in 3D space This operation can be easily to extended to **3D space** by adding a third dimension to the input arrays and the output array. ```js const midpoint3D = ([x1, y1, z1], [x2, y2, z2]) => [ (x1 + x2) / 2, (y1 + y2) / 2, (z1 + z2) / 2, ]; midpoint3...
code_snippets
727b797f-8349-49e8-8878-b77a48d94ff9
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/midpoint.md
unknown
1303ce41-e85e-42e9-bd6d-e9e4ea8b20ad
0
SemanticChunker@1.0.0
05c426d60e4b1165ca30264d49daec1c841792c95de21d5b53820f0c64499f51
--- title: Midpoint of two points shortTitle: Midpoint language: javascript tags: [math] cover: blue-flower excerpt: Calculate the midpoint between two pairs of points in a 2D plane, and beyond. listed: true dateModified: 2024-05-15 --- Given two points in a **2D plane**, you can calculate the midpoint between them by...
unknown
unknown
--- title: Midpoint of two points shortTitle: Midpoint language: javascript tags: [math] cover: blue-flower excerpt: Calculate the midpoint between two pairs of points in a 2D plane, and beyond. listed: true dateModified: 2024-05-15 --- Given two points in a **2D plane**, you can calculate the midpoint between them by...
--- title: Midpoint of two points shortTitle: Midpoint language: javascript tags: [math] cover: blue-flower excerpt: Calculate the midpoint between two pairs of points in a 2D plane, and beyond. listed: true dateModified: 2024-05-15 --- Given two points in a **2D plane**, you can calculate the midpoint between them by...
code_snippets
86f8d0db-4c81-49aa-9b3b-ee2ec30f5ffe
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/midpoint.md
unknown
1303ce41-e85e-42e9-bd6d-e9e4ea8b20ad
3
SemanticChunker@1.0.0
8d281b5eef87c8893d9dfd7c1941602851a0043df3f84d5e19be0fb142bf8158
[Midpoint in 2D space > Midpoint in N-dimensional space] ## Midpoint in N-dimensional space In fact, you can extend this operation to **any number of dimensions** by adding more elements to the input arrays and the output array. The formula remains the same, but you will have to use `Array.prototype.map()` to iterate...
unknown
unknown
[Midpoint in 2D space > Midpoint in N-dimensional space] ## Midpoint in N-dimensional space In fact, you can extend this operation to **any number of dimensions** by adding more elements to the input arrays and the output array. The formula remains the same, but you will have to use `Array.prototype.map()` to iterate...
[Midpoint in 2D space > Midpoint in N-dimensional space] ## Midpoint in N-dimensional space In fact, you can extend this operation to **any number of dimensions** by adding more elements to the input arrays and the output array. The formula remains the same, but you will have to use `Array.prototype.map()` to iterate...
code_snippets
9899737c-8e12-4e79-a433-ca3a1f2b3c4c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/midpoint.md
unknown
1303ce41-e85e-42e9-bd6d-e9e4ea8b20ad
1
SemanticChunker@1.0.0
9a4561eac15e93fd1f59072b427be8d2f887e8af2cb476cd724d4855e0299a40
[Midpoint in 2D space] ## Midpoint in 2D space First off, you can use **array destructuring** to extract the x and y coordinates of the two points from the input arrays. Then, you can calculate the midpoint for each dimension by adding the two endpoints and dividing the result by 2. ```js const midpoint = ([x1, y1],...
unknown
unknown
[Midpoint in 2D space] ## Midpoint in 2D space First off, you can use **array destructuring** to extract the x and y coordinates of the two points from the input arrays. Then, you can calculate the midpoint for each dimension by adding the two endpoints and dividing the result by 2. ```js const midpoint = ([x1, y1],...
[Midpoint in 2D space] ## Midpoint in 2D space First off, you can use **array destructuring** to extract the x and y coordinates of the two points from the input arrays. Then, you can calculate the midpoint for each dimension by adding the two endpoints and dividing the result by 2. ```js const midpoint = ([x1, y1],...
code_snippets
f8e41cca-8d98-43af-b221-fdf4a2360a28
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/min-max-date.md
unknown
afa25afc-a7df-4718-aa56-a8484ff337fd
0
SemanticChunker@1.0.0
bc8afc87f6bf7f002067f09024db3e8212585b0992439f3193967d9d29b029f1
--- title: Find the minimum or maximum date using JavaScript shortTitle: Min or max date language: javascript tags: [date] cover: interior-2 excerpt: Quickly find the minimum or maximum date in an array of dates. listed: true dateModified: 2024-01-06 --- At a fundamental level, JavaScript `Date` objects are **just num...
unknown
unknown
--- title: Find the minimum or maximum date using JavaScript shortTitle: Min or max date language: javascript tags: [date] cover: interior-2 excerpt: Quickly find the minimum or maximum date in an array of dates. listed: true dateModified: 2024-01-06 --- At a fundamental level, JavaScript `Date` objects are **just num...
--- title: Find the minimum or maximum date using JavaScript shortTitle: Min or max date language: javascript tags: [date] cover: interior-2 excerpt: Quickly find the minimum or maximum date in an array of dates. listed: true dateModified: 2024-01-06 --- At a fundamental level, JavaScript `Date` objects are **just num...
code_snippets
5e5c218c-b0b8-4944-b436-00a097f79984
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-sort.md
unknown
004d393c-fdda-48eb-a28f-becb7b255d89
2
SemanticChunker@1.0.0
f119ae92a19775f059cb23d7e793b8de29be73c6ccbb4682d7c59203fda07176
[Definition > Implementation] ## Implementation - Use recursion. - If the `length` of the array is less than `2`, return the array. - Use `Math.floor()` to calculate the middle point of the array. - Use `Array.prototype.slice()` to slice the array in two and recursively call `mergeSort()` on the created subarrays. - ...
unknown
unknown
[Definition > Implementation] ## Implementation - Use recursion. - If the `length` of the array is less than `2`, return the array. - Use `Math.floor()` to calculate the middle point of the array. - Use `Array.prototype.slice()` to slice the array in two and recursively call `mergeSort()` on the created subarrays. - ...
[Definition > Implementation] ## Implementation - Use recursion. - If the `length` of the array is less than `2`, return the array. - Use `Math.floor()` to calculate the middle point of the array. - Use `Array.prototype.slice()` to slice the array in two and recursively call `mergeSort()` on the created subarrays. - ...
code_snippets
6e5b58af-0119-4577-877a-83d20f52e2f8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-sort.md
unknown
004d393c-fdda-48eb-a28f-becb7b255d89
1
SemanticChunker@1.0.0
337b3d2a3ba8b622f2090a46d8780661899c984740686527ae51379e4ce38320
[Definition] ## Definition [Merge sort](https://en.wikipedia.org/wiki/Merge_sort) is an **efficient, general-purpose, comparison-based sorting algorithm**. Merge sort is a **divide and conquer algorithm**, based on the idea of breaking down a array into several subarrays until each one consists of a single element an...
unknown
unknown
[Definition] ## Definition [Merge sort](https://en.wikipedia.org/wiki/Merge_sort) is an **efficient, general-purpose, comparison-based sorting algorithm**. Merge sort is a **divide and conquer algorithm**, based on the idea of breaking down a array into several subarrays until each one consists of a single element an...
[Definition] ## Definition [Merge sort](https://en.wikipedia.org/wiki/Merge_sort) is an **efficient, general-purpose, comparison-based sorting algorithm**. Merge sort is a **divide and conquer algorithm**, based on the idea of breaking down a array into several subarrays until each one consists of a single element an...
code_snippets
cc808871-ee73-48c3-a400-2ba890dc45ac
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-sort.md
unknown
004d393c-fdda-48eb-a28f-becb7b255d89
0
SemanticChunker@1.0.0
4a225155f7384b0d5a36b19e741a277626a5a158f1602417738d46512ad290b2
--- title: Merge sort language: javascript tags: [algorithm,array,recursion] cover: balloons-field excerpt: Sort an array of numbers, using the merge sort algorithm. listed: true dateModified: 2023-12-16 ---
unknown
unknown
--- title: Merge sort language: javascript tags: [algorithm,array,recursion] cover: balloons-field excerpt: Sort an array of numbers, using the merge sort algorithm. listed: true dateModified: 2023-12-16 ---
--- title: Merge sort language: javascript tags: [algorithm,array,recursion] cover: balloons-field excerpt: Sort an array of numbers, using the merge sort algorithm. listed: true dateModified: 2023-12-16 ---
code_snippets
38e756e0-fddf-48f6-a1de-e2667c7f4c64
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-objects.md
unknown
d7f74017-06c0-4418-bb91-d1a74f6e90c5
1
SemanticChunker@1.0.0
81ab53fe0d685045466e0a81f38116032e32891f15987a164249b5f713bc4055
[Built-in methods] ## Built-in methods Both the spread operator (`...`) and `Object.assign()` can be used to merge two or more objects into a single object. However, these methods only perform a **shallow merge**, meaning that nested objects are not merged. They also have the drawback of **overwriting properties with...
unknown
unknown
[Built-in methods] ## Built-in methods Both the spread operator (`...`) and `Object.assign()` can be used to merge two or more objects into a single object. However, these methods only perform a **shallow merge**, meaning that nested objects are not merged. They also have the drawback of **overwriting properties with...
[Built-in methods] ## Built-in methods Both the spread operator (`...`) and `Object.assign()` can be used to merge two or more objects into a single object. However, these methods only perform a **shallow merge**, meaning that nested objects are not merged. They also have the drawback of **overwriting properties with...
code_snippets
a5b4c01f-7c4f-4486-8488-232639ddea6a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-objects.md
unknown
d7f74017-06c0-4418-bb91-d1a74f6e90c5
2
SemanticChunker@1.0.0
6c5f73c7b315458e0710af04c77d410ae99e2ce32317c445df727b36a582838f
[Built-in methods > Combining values with the same key] ## Combining values with the same key Instead of overwriting properties with the same key, we usually want to combine their values. This can be done by **checking if the key already exists** in the resulting object and appending the value to an array if it does....
unknown
unknown
[Built-in methods > Combining values with the same key] ## Combining values with the same key Instead of overwriting properties with the same key, we usually want to combine their values. This can be done by **checking if the key already exists** in the resulting object and appending the value to an array if it does....
[Built-in methods > Combining values with the same key] ## Combining values with the same key Instead of overwriting properties with the same key, we usually want to combine their values. This can be done by **checking if the key already exists** in the resulting object and appending the value to an array if it does....
code_snippets
a5f13bf7-4d6a-4c90-9b39-5daff4bcdd72
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-objects.md
unknown
d7f74017-06c0-4418-bb91-d1a74f6e90c5
0
SemanticChunker@1.0.0
ae79a3db9583ede74f2405d75b779277caa64c4a86d1beca19e5e06e7810dd1a
--- title: Merge two or more JavaScript objects shortTitle: Merge objects language: javascript tags: [object,array] cover: guitar-living-room excerpt: Learn how to combine two or more objects into a single object in JavaScript. listed: true dateModified: 2024-03-20 --- JavaScript arrays are fairly easy to merge, using...
unknown
unknown
--- title: Merge two or more JavaScript objects shortTitle: Merge objects language: javascript tags: [object,array] cover: guitar-living-room excerpt: Learn how to combine two or more objects into a single object in JavaScript. listed: true dateModified: 2024-03-20 --- JavaScript arrays are fairly easy to merge, using...
--- title: Merge two or more JavaScript objects shortTitle: Merge objects language: javascript tags: [object,array] cover: guitar-living-room excerpt: Learn how to combine two or more objects into a single object in JavaScript. listed: true dateModified: 2024-03-20 --- JavaScript arrays are fairly easy to merge, using...
code_snippets
e51d2902-f75f-4032-9f30-09c723e73c3e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-objects.md
unknown
d7f74017-06c0-4418-bb91-d1a74f6e90c5
3
SemanticChunker@1.0.0
fa94d930da7f63b67b8189cb0dec6a056f7a4ef3187d5341d288067d6a1e97b2
[Built-in methods > Deeply merging objects] ## Deeply merging objects If you need to merge objects that contain **nested objects**, you might want to handle nested values differently. This can be done by passing a function that handles the merging of individual keys, allowing you to **customize the merging process**....
unknown
unknown
[Built-in methods > Deeply merging objects] ## Deeply merging objects If you need to merge objects that contain **nested objects**, you might want to handle nested values differently. This can be done by passing a function that handles the merging of individual keys, allowing you to **customize the merging process**....
[Built-in methods > Deeply merging objects] ## Deeply merging objects If you need to merge objects that contain **nested objects**, you might want to handle nested values differently. This can be done by passing a function that handles the merging of individual keys, allowing you to **customize the merging process**....
code_snippets
266efd91-4e9a-4851-b36c-c5ce8d12f1d1
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/memoization.md
unknown
cdae0709-823c-47b9-a12f-7373a0df4753
0
SemanticChunker@1.0.0
fa4e3934b2140d625021c71e7ae9a6e5303cb85cca26da25a7a38c9645bf802c
--- title: Where and how can I use memoization in JavaScript? shortTitle: Memoization introduction language: javascript tags: [function,memoization] cover: cherry-trees excerpt: Learn different ways to memoize function calls in JavaScript as well as when to use memoization to get the best performance results. listed: t...
unknown
unknown
--- title: Where and how can I use memoization in JavaScript? shortTitle: Memoization introduction language: javascript tags: [function,memoization] cover: cherry-trees excerpt: Learn different ways to memoize function calls in JavaScript as well as when to use memoization to get the best performance results. listed: t...
--- title: Where and how can I use memoization in JavaScript? shortTitle: Memoization introduction language: javascript tags: [function,memoization] cover: cherry-trees excerpt: Learn different ways to memoize function calls in JavaScript as well as when to use memoization to get the best performance results. listed: t...
code_snippets
370cb89a-66eb-48e4-936e-030147df0435
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/memoization.md
unknown
cdae0709-823c-47b9-a12f-7373a0df4753
4
SemanticChunker@1.0.0
c09b88bf0d44715ed217c8ed28cde463060e8c2f2f01c8986db02e355ae4a3a3
[What is memoization? > Using a Proxy object for memoization] ## Using a Proxy object for memoization While the previous example is a good way to implement memoization, JavaScript's [Proxy object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) provides an interesting **alterna...
unknown
unknown
[What is memoization? > Using a Proxy object for memoization] ## Using a Proxy object for memoization While the previous example is a good way to implement memoization, JavaScript's [Proxy object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) provides an interesting **alterna...
[What is memoization? > Using a Proxy object for memoization] ## Using a Proxy object for memoization While the previous example is a good way to implement memoization, JavaScript's [Proxy object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) provides an interesting **alterna...
code_snippets
56229f79-74f1-40da-a34f-aac221225c66
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/memoization.md
unknown
cdae0709-823c-47b9-a12f-7373a0df4753
3
SemanticChunker@1.0.0
ef2078b660776c17439b9573bcfd96c55d4ff6b713f11d96e098d379e5d87158
[What is memoization? > Memoize a function] ## Memoize a function It's fairly easy to roll up your own memoization function in JavaScript. For this implementation, we'll use a `Map` to store the results. The `Map` object holds **key-value pairs** and remembers the original insertion order of the keys. This makes it s...
unknown
unknown
[What is memoization? > Memoize a function] ## Memoize a function It's fairly easy to roll up your own memoization function in JavaScript. For this implementation, we'll use a `Map` to store the results. The `Map` object holds **key-value pairs** and remembers the original insertion order of the keys. This makes it s...
[What is memoization? > Memoize a function] ## Memoize a function It's fairly easy to roll up your own memoization function in JavaScript. For this implementation, we'll use a `Map` to store the results. The `Map` object holds **key-value pairs** and remembers the original insertion order of the keys. This makes it s...
code_snippets
879e3561-8904-427f-b58b-b43ce31d0709
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/memoization.md
unknown
cdae0709-823c-47b9-a12f-7373a0df4753
2
SemanticChunker@1.0.0
0c51127b8cb27a6fbc1fc7d0da3f9163982e2041aab29c097e7e54832a175704
[What is memoization? > Criteria for using memoization] ## Criteria for using memoization Based on its definition, we can easily deduce some criteria to help us discover good candidates for memoization: - **Slow-performing, costly or time-consuming** function calls can benefit from memoization - Memoization speeds u...
unknown
unknown
[What is memoization? > Criteria for using memoization] ## Criteria for using memoization Based on its definition, we can easily deduce some criteria to help us discover good candidates for memoization: - **Slow-performing, costly or time-consuming** function calls can benefit from memoization - Memoization speeds u...
[What is memoization? > Criteria for using memoization] ## Criteria for using memoization Based on its definition, we can easily deduce some criteria to help us discover good candidates for memoization: - **Slow-performing, costly or time-consuming** function calls can benefit from memoization - Memoization speeds u...
code_snippets
f5f85de1-c3f5-44ef-97d6-811d9df04896
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/memoization.md
unknown
cdae0709-823c-47b9-a12f-7373a0df4753
1
SemanticChunker@1.0.0
12236442be9fae120100d3ff92303b26f16fa00c21ed585a79ceb57f19219274
[What is memoization?] ## What is memoization? Memoization is a commonly used technique that can help speed up your code significantly. It relies on a **cache** to store results for previously completed units of work. The purpose of the cache is to **avoid performing the same work more than once**, speeding up subseq...
unknown
unknown
[What is memoization?] ## What is memoization? Memoization is a commonly used technique that can help speed up your code significantly. It relies on a **cache** to store results for previously completed units of work. The purpose of the cache is to **avoid performing the same work more than once**, speeding up subseq...
[What is memoization?] ## What is memoization? Memoization is a commonly used technique that can help speed up your code significantly. It relies on a **cache** to store results for previously completed units of work. The purpose of the cache is to **avoid performing the same work more than once**, speeding up subseq...
code_snippets
5715bd61-ddfc-433f-ac5d-44af6024ea2b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-arrays.md
unknown
8f76052a-1682-4d05-afe3-8bc89e685215
3
SemanticChunker@1.0.0
68cd8d973ff58c78b9c9d04378d0f89898cc83f5daabffa8afa826867dc746a7
[Spread operator > Comparing the two] ## Comparing the two The spread operator version is definitely shorter and as readable as the `Array.prototype.concat()` one. Apart from that, the spread operator seems to be slightly faster based on [some benchmarks I have performed](https://jsben.ch/9txyg) (as of **Aug, 2020 on...
unknown
unknown
[Spread operator > Comparing the two] ## Comparing the two The spread operator version is definitely shorter and as readable as the `Array.prototype.concat()` one. Apart from that, the spread operator seems to be slightly faster based on [some benchmarks I have performed](https://jsben.ch/9txyg) (as of **Aug, 2020 on...
[Spread operator > Comparing the two] ## Comparing the two The spread operator version is definitely shorter and as readable as the `Array.prototype.concat()` one. Apart from that, the spread operator seems to be slightly faster based on [some benchmarks I have performed](https://jsben.ch/9txyg) (as of **Aug, 2020 on...
code_snippets
78879116-e650-4bc0-8eff-6a193dafd12b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-arrays.md
unknown
8f76052a-1682-4d05-afe3-8bc89e685215
2
SemanticChunker@1.0.0
5bef09aefd63a910ac9ccdec71f338ef7e83bc7f04622db69ba0796aa8e3c73c
[Spread operator > Array.prototype.concat()] ## Array.prototype.concat() [`Array.prototype.concat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) is a method on the `Array` prototype and can be used to create a new array, either by concatenating both arrays to a new ...
unknown
unknown
[Spread operator > Array.prototype.concat()] ## Array.prototype.concat() [`Array.prototype.concat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) is a method on the `Array` prototype and can be used to create a new array, either by concatenating both arrays to a new ...
[Spread operator > Array.prototype.concat()] ## Array.prototype.concat() [`Array.prototype.concat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) is a method on the `Array` prototype and can be used to create a new array, either by concatenating both arrays to a new ...
code_snippets
c6cf4d97-2289-41e6-b2ec-7440c215aabb
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-arrays.md
unknown
8f76052a-1682-4d05-afe3-8bc89e685215
0
SemanticChunker@1.0.0
6e189bdee0047daf726f5fa203ffbb1bfa4784bcc9cb99e0603cb98b4c82b5f1
--- title: How do I merge two arrays in JavaScript? shortTitle: Merge arrays language: javascript tags: [array] cover: arrays excerpt: Arrays are one of the most used data types in any programming language. Learn how to merge two arrays in JavaScript with this short guide. listed: true dateModified: 2021-06-12 ---
unknown
unknown
--- title: How do I merge two arrays in JavaScript? shortTitle: Merge arrays language: javascript tags: [array] cover: arrays excerpt: Arrays are one of the most used data types in any programming language. Learn how to merge two arrays in JavaScript with this short guide. listed: true dateModified: 2021-06-12 ---
--- title: How do I merge two arrays in JavaScript? shortTitle: Merge arrays language: javascript tags: [array] cover: arrays excerpt: Arrays are one of the most used data types in any programming language. Learn how to merge two arrays in JavaScript with this short guide. listed: true dateModified: 2021-06-12 ---
code_snippets
faedd5a2-92f1-4d92-b931-1c6cce3d6d99
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/merge-arrays.md
unknown
8f76052a-1682-4d05-afe3-8bc89e685215
1
SemanticChunker@1.0.0
ea5471cc43a4bfac104873d5e6696c36d080a84d6766f31ad8254fed17ab2794
[Spread operator] ## Spread operator The [spread operator (`...`)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) was introduced in ES6 and can be used to merge two or more arrays, by spreading each one inside a new array: ```js const a = [1, 2, 3]; const b = [4, 5, 6]; c...
unknown
unknown
[Spread operator] ## Spread operator The [spread operator (`...`)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) was introduced in ES6 and can be used to merge two or more arrays, by spreading each one inside a new array: ```js const a = [1, 2, 3]; const b = [4, 5, 6]; c...
[Spread operator] ## Spread operator The [spread operator (`...`)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax) was introduced in ES6 and can be used to merge two or more arrays, by spreading each one inside a new array: ```js const a = [1, 2, 3]; const b = [4, 5, 6]; c...
code_snippets
849f361d-5712-421a-92a8-99b850b5ced4
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/max-subarray.md
unknown
dd50d5f8-da16-4640-97de-34dc441d6caa
0
SemanticChunker@1.0.0
028e429cf08daaffe1e03b2fdb4aea33d7adbad6f4666125b446798ce5eedd5b
--- title: Find the maximum subarray of a JavaScript array shortTitle: Maximum subarray language: javascript tags: [algorithm,math,array] cover: work-hard-computer excerpt: Learn how to find the contiguous subarray with the largest sum within an array of numbers in JavaScript. listed: true dateModified: 2024-08-03 --- ...
unknown
unknown
--- title: Find the maximum subarray of a JavaScript array shortTitle: Maximum subarray language: javascript tags: [algorithm,math,array] cover: work-hard-computer excerpt: Learn how to find the contiguous subarray with the largest sum within an array of numbers in JavaScript. listed: true dateModified: 2024-08-03 --- ...
--- title: Find the maximum subarray of a JavaScript array shortTitle: Maximum subarray language: javascript tags: [algorithm,math,array] cover: work-hard-computer excerpt: Learn how to find the contiguous subarray with the largest sum within an array of numbers in JavaScript. listed: true dateModified: 2024-08-03 --- ...
code_snippets
07069a5d-3db0-4834-ba6c-f6f46ea3addd
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modify-url-without-reload.md
unknown
a3d6294e-e0b6-46e0-9d3b-a9703acb8bef
2
SemanticChunker@1.0.0
5728c6bab1515b4ed2f77a96391d027e732724cef13642b1ffbf61e9d5263199
[Using the History API > Update the URL] ### Update the URL Using the History API, you can create a **function that updates the URL of the current page without reloading it**. This function can be used to **simulate a navigation event**, without actually navigating to a different page. Depending on your needs, you ca...
unknown
unknown
[Using the History API > Update the URL] ### Update the URL Using the History API, you can create a **function that updates the URL of the current page without reloading it**. This function can be used to **simulate a navigation event**, without actually navigating to a different page. Depending on your needs, you ca...
[Using the History API > Update the URL] ### Update the URL Using the History API, you can create a **function that updates the URL of the current page without reloading it**. This function can be used to **simulate a navigation event**, without actually navigating to a different page. Depending on your needs, you ca...
code_snippets
18f2ac4a-4ce9-4b4d-93a4-e4dc0191240b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modify-url-without-reload.md
unknown
a3d6294e-e0b6-46e0-9d3b-a9703acb8bef
0
SemanticChunker@1.0.0
82bd8dc42dbcdd0bbae5bbae6553edc23fc2a2e370c768d3fd1a6b9a97ab8be1
--- title: How do I use JavaScript to modify the URL without reloading the page? shortTitle: Modify URL without reloading language: javascript tags: [browser] cover: compass excerpt: Learn all of the options JavaScript provides for modifying the URL of the current page in the browser without reloading the page. listed:...
unknown
unknown
--- title: How do I use JavaScript to modify the URL without reloading the page? shortTitle: Modify URL without reloading language: javascript tags: [browser] cover: compass excerpt: Learn all of the options JavaScript provides for modifying the URL of the current page in the browser without reloading the page. listed:...
--- title: How do I use JavaScript to modify the URL without reloading the page? shortTitle: Modify URL without reloading language: javascript tags: [browser] cover: compass excerpt: Learn all of the options JavaScript provides for modifying the URL of the current page in the browser without reloading the page. listed:...
code_snippets
caf8f6f6-be1e-4aed-81c9-bccd88d29001
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modify-url-without-reload.md
unknown
a3d6294e-e0b6-46e0-9d3b-a9703acb8bef
4
SemanticChunker@1.0.0
0d847399312599f14bec5a02da9ebf99c5b080d12298cd3ff48403196a29e2e2
[Using the Location API > Redirect to a URL] ### Redirect to a URL Using the Location API, it's pretty easy to create a **function that redirects to the specified URL**, using `Window.location.href` or `Window.location.replace()`. Additionally, we can leverage the function's arguments to simulate a link click (`true`...
unknown
unknown
[Using the Location API > Redirect to a URL] ### Redirect to a URL Using the Location API, it's pretty easy to create a **function that redirects to the specified URL**, using `Window.location.href` or `Window.location.replace()`. Additionally, we can leverage the function's arguments to simulate a link click (`true`...
[Using the Location API > Redirect to a URL] ### Redirect to a URL Using the Location API, it's pretty easy to create a **function that redirects to the specified URL**, using `Window.location.href` or `Window.location.replace()`. Additionally, we can leverage the function's arguments to simulate a link click (`true`...
code_snippets
d2058879-a952-4ee3-993e-54d5921cf416
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modify-url-without-reload.md
unknown
a3d6294e-e0b6-46e0-9d3b-a9703acb8bef
1
SemanticChunker@1.0.0
9a212e0c38749b68a21448c13fdd7eb1dd07e835205c4cc32a4a9f69cc04408b
[Using the History API] ## Using the History API The HTML5 [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) is definitely the way to go for modern websites. It accomplishes the task at hand, while also providing additional functionality. You can use either `history.pushState()` or `history....
unknown
unknown
[Using the History API] ## Using the History API The HTML5 [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) is definitely the way to go for modern websites. It accomplishes the task at hand, while also providing additional functionality. You can use either `history.pushState()` or `history....
[Using the History API] ## Using the History API The HTML5 [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) is definitely the way to go for modern websites. It accomplishes the task at hand, while also providing additional functionality. You can use either `history.pushState()` or `history....
code_snippets
eb1b376b-e4ee-4ffd-afc1-4d14d5131000
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modify-url-without-reload.md
unknown
a3d6294e-e0b6-46e0-9d3b-a9703acb8bef
3
SemanticChunker@1.0.0
0b5a6d7324b7bb1b51773299a714fa45b19e300bbb6e9bca131b8c4b22a7ee0a
[Using the History API > Using the Location API] ## Using the Location API The older [Location API](https://developer.mozilla.org/en-US/docs/Web/API/Location) is not the best tool for the job. It **reloads the page**, but still allows you to modify the current URL and might be useful when working with **legacy browse...
unknown
unknown
[Using the History API > Using the Location API] ## Using the Location API The older [Location API](https://developer.mozilla.org/en-US/docs/Web/API/Location) is not the best tool for the job. It **reloads the page**, but still allows you to modify the current URL and might be useful when working with **legacy browse...
[Using the History API > Using the Location API] ## Using the Location API The older [Location API](https://developer.mozilla.org/en-US/docs/Web/API/Location) is not the best tool for the job. It **reloads the page**, but still allows you to modify the current URL and might be useful when working with **legacy browse...
code_snippets
047c940a-ba59-47d2-bb30-f1f4fc3a0212
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
11
SemanticChunker@1.0.0
95039c97a96981ddc7692fab7489ae50e88505d0f48c46eb448a91ce411ce344
[Matrix operations > Transpose] ### Transpose The **transpose** of a matrix is a new matrix whose rows are the columns of the original matrix. This is a very common operation in linear algebra and is often used in machine learning and data science. @[Quick refresher](/js/s/transpose-matrix) ```js class Matrix { tr...
unknown
unknown
[Matrix operations > Transpose] ### Transpose The **transpose** of a matrix is a new matrix whose rows are the columns of the original matrix. This is a very common operation in linear algebra and is often used in machine learning and data science. @[Quick refresher](/js/s/transpose-matrix) ```js class Matrix { tr...
[Matrix operations > Transpose] ### Transpose The **transpose** of a matrix is a new matrix whose rows are the columns of the original matrix. This is a very common operation in linear algebra and is often used in machine learning and data science. @[Quick refresher](/js/s/transpose-matrix) ```js class Matrix { tr...
code_snippets
119ad5fe-4424-49f6-89ac-bc7f158250ed
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
15
SemanticChunker@1.0.0
d75155ebcf4a14bdb186688eefcb378ac80f5734882006cc401454fe63278d1a
[Data structure > Predicate matching] lastIndexOf(value) { for (let i = this.rows - 1; i >= 0; i--) for (let j = this.cols - 1; j >= 0; j--) if (this.data[i][j] === value) return [i, j]; return undefined; } } ``` ## Other array operations Native JavaScript arrays have, after ES6, a whole host of useful method...
unknown
unknown
[Data structure > Predicate matching] lastIndexOf(value) { for (let i = this.rows - 1; i >= 0; i--) for (let j = this.cols - 1; j >= 0; j--) if (this.data[i][j] === value) return [i, j]; return undefined; } } ``` ## Other array operations Native JavaScript arrays have, after ES6, a whole host of useful method...
[Data structure > Predicate matching] lastIndexOf(value) { for (let i = this.rows - 1; i >= 0; i--) for (let j = this.cols - 1; j >= 0; j--) if (this.data[i][j] === value) return [i, j]; return undefined; } } ``` ## Other array operations Native JavaScript arrays have, after ES6, a whole host of useful method...
code_snippets
23f49030-214e-4400-b3ab-57d398affcf6
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
6
SemanticChunker@1.0.0
168905dbe0ba8c601a3d5d4fb263f7a3ce7c9c8b67e81f51b8dee00b32763ef5
[Math operations > Basic math operations] ### Basic math operations Basic mathematical operations form the foundation of other matrix operations and are very common in many use cases. We'll add the following methods: - `add`: Adds two matrices together. - `subtract`: Subtracts one matrix from another. - `multiply`: ...
unknown
unknown
[Math operations > Basic math operations] ### Basic math operations Basic mathematical operations form the foundation of other matrix operations and are very common in many use cases. We'll add the following methods: - `add`: Adds two matrices together. - `subtract`: Subtracts one matrix from another. - `multiply`: ...
[Math operations > Basic math operations] ### Basic math operations Basic mathematical operations form the foundation of other matrix operations and are very common in many use cases. We'll add the following methods: - `add`: Adds two matrices together. - `subtract`: Subtracts one matrix from another. - `multiply`: ...
code_snippets
41a6d145-fe10-4958-b26c-4c117788f257
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
2
SemanticChunker@1.0.0
084a6fbd70a9e756f1bcf167daa780e5280a3f890b32a72b02a836b49a8f64e7
[Data structure > Initialization] ## Initialization Before we can **initialize the data** in the matrix, we'll need some methods to help us with that. I'm going to add the following for starters: - `fill`: Fills the matrix with a specific value. - `copy`: Creates a deep copy of the matrix. Let's also add some **sta...
unknown
unknown
[Data structure > Initialization] ## Initialization Before we can **initialize the data** in the matrix, we'll need some methods to help us with that. I'm going to add the following for starters: - `fill`: Fills the matrix with a specific value. - `copy`: Creates a deep copy of the matrix. Let's also add some **sta...
[Data structure > Initialization] ## Initialization Before we can **initialize the data** in the matrix, we'll need some methods to help us with that. I'm going to add the following for starters: - `fill`: Fills the matrix with a specific value. - `copy`: Creates a deep copy of the matrix. Let's also add some **sta...
code_snippets
62bc0b6f-2ec7-43ea-b6d1-fce9273cdf65
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
4
SemanticChunker@1.0.0
70fe9256ac074b36b902a99d70a61ba10053a7748f585a807f75f844d1a06069
[Data structure > Accessing values] ## Accessing values Again, drawing inspiration from native data structures, I added some methods to **access the matrix data**, either as single values or as slices. The following methods are available: - `get`: Returns the value at the given indexes (`i, j`). - `set`: Sets the va...
unknown
unknown
[Data structure > Accessing values] ## Accessing values Again, drawing inspiration from native data structures, I added some methods to **access the matrix data**, either as single values or as slices. The following methods are available: - `get`: Returns the value at the given indexes (`i, j`). - `set`: Sets the va...
[Data structure > Accessing values] ## Accessing values Again, drawing inspiration from native data structures, I added some methods to **access the matrix data**, either as single values or as slices. The following methods are available: - `get`: Returns the value at the given indexes (`i, j`). - `set`: Sets the va...
code_snippets
683d73a7-652d-4c55-9bb1-10746045e9d3
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
12
SemanticChunker@1.0.0
b3039ad4fd7619ae60d018bf348feccaa0584b89df846a2ad6f43c1d0e1de50c
[Matrix operations > Diagonal & trace] ### Diagonal & trace The **diagonal** of a matrix is a 1D vector that contains the elements of the matrix that are on the diagonal. Similarly, the **trace** of a matrix is the sum of the elements on the diagonal. Both are pretty common in many areas of programming. ```js collap...
unknown
unknown
[Matrix operations > Diagonal & trace] ### Diagonal & trace The **diagonal** of a matrix is a 1D vector that contains the elements of the matrix that are on the diagonal. Similarly, the **trace** of a matrix is the sum of the elements on the diagonal. Both are pretty common in many areas of programming. ```js collap...
[Matrix operations > Diagonal & trace] ### Diagonal & trace The **diagonal** of a matrix is a 1D vector that contains the elements of the matrix that are on the diagonal. Similarly, the **trace** of a matrix is the sum of the elements on the diagonal. Both are pretty common in many areas of programming. ```js collap...
code_snippets
782f303e-765c-480b-9e79-953cb90420ee
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
14
SemanticChunker@1.0.0
5e378c1fb233c13e9dd89fc1d20e15fb4bc5f1e83558b320f978a83c86c6429e
[Data structure > Predicate matching] ## Predicate matching Native JavaScript arrays have a lot of methods for **matching values**, such as `find`, `some`, `every`, and so on. The same behavior is easy enough to implement for our matrix class, so let's add the following methods: - `every` / `some`: Check if all or s...
unknown
unknown
[Data structure > Predicate matching] ## Predicate matching Native JavaScript arrays have a lot of methods for **matching values**, such as `find`, `some`, `every`, and so on. The same behavior is easy enough to implement for our matrix class, so let's add the following methods: - `every` / `some`: Check if all or s...
[Data structure > Predicate matching] ## Predicate matching Native JavaScript arrays have a lot of methods for **matching values**, such as `find`, `some`, `every`, and so on. The same behavior is easy enough to implement for our matrix class, so let's add the following methods: - `every` / `some`: Check if all or s...
code_snippets
7a89f2c4-de92-48d7-b7c1-ee40358f9a53
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
13
SemanticChunker@1.0.0
fd06e246e15c98b7c8fefd213e794562e0c6a41eed071c48ac41177fc06039c3
[Matrix operations > Diagonal & trace] ``` ### Determinant & submatrices The **determinant** of a matrix is a scalar value that can be calculated from the elements of a square matrix. It is a very important concept in linear algebra, but it takes a little bit of work to implement. In order to calculate it, we need ...
unknown
unknown
[Matrix operations > Diagonal & trace] ``` ### Determinant & submatrices The **determinant** of a matrix is a scalar value that can be calculated from the elements of a square matrix. It is a very important concept in linear algebra, but it takes a little bit of work to implement. In order to calculate it, we need ...
[Matrix operations > Diagonal & trace] ``` ### Determinant & submatrices The **determinant** of a matrix is a scalar value that can be calculated from the elements of a square matrix. It is a very important concept in linear algebra, but it takes a little bit of work to implement. In order to calculate it, we need ...
code_snippets
847ad35b-fab7-47ff-aaa5-7aff120313f7
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
16
SemanticChunker@1.0.0
6dc1cbd5d8e7f9fbd1b494bb2ae22734108a4bd115882be46a5669a804c1544b
[Predicate matching > Flattening] ### Flattening **Flattening** a matrix is pretty simple as, in essence, it's just a 2D array. Naturally, `flat` and `flatMap` are pretty easy to implement. ```js class Matrix { flat() { return this.data.flat(2); } flatMap(callback) { return this.map(callback).flat(); } } ```
unknown
unknown
[Predicate matching > Flattening] ### Flattening **Flattening** a matrix is pretty simple as, in essence, it's just a 2D array. Naturally, `flat` and `flatMap` are pretty easy to implement. ```js class Matrix { flat() { return this.data.flat(2); } flatMap(callback) { return this.map(callback).flat(); } } ```
[Predicate matching > Flattening] ### Flattening **Flattening** a matrix is pretty simple as, in essence, it's just a 2D array. Naturally, `flat` and `flatMap` are pretty easy to implement. ```js class Matrix { flat() { return this.data.flat(2); } flatMap(callback) { return this.map(callback).flat(); } } ```
code_snippets
852348f3-a6ca-4b63-85f3-ed93ecb9becf
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
9
SemanticChunker@1.0.0
e84b8385548b548409c2ba5d9a3330b55794951f66cd666b24ad06a6932c7214
[Math operations > Basic math operations] ``` # [continued: part 2] stdPerCol() { return this.variancePerCol().map(variance => Math.sqrt(variance)); } cumulativeSum() { const result = Array.from({ length: this.rows }, () => []); let lastValue = 0; for (let [i, j, value] of this.entries()) { lastValue += val...
unknown
unknown
[Math operations > Basic math operations] ``` # [continued: part 2] stdPerCol() { return this.variancePerCol().map(variance => Math.sqrt(variance)); } cumulativeSum() { const result = Array.from({ length: this.rows }, () => []); let lastValue = 0; for (let [i, j, value] of this.entries()) { lastValue += val...
[Math operations > Basic math operations] ``` # [continued: part 2] stdPerCol() { return this.variancePerCol().map(variance => Math.sqrt(variance)); } cumulativeSum() { const result = Array.from({ length: this.rows }, () => []); let lastValue = 0; for (let [i, j, value] of this.entries()) { lastValue += val...
code_snippets
857443e0-6b28-4389-bd31-a191857c7181
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
3
SemanticChunker@1.0.0
5df45b368a3046afd0dff30d2877025d5e620006d6a908bc2bc6242267afe8ce
[Data structure > Iteration] ## Iteration Iterating over the matrix should be as painless as possible. Taking inspiration from the `Map` native data structure, I opted to add the following methods that return **iterators**: - `indexes`: Returns an iterator that yields the indexes of the matrix. - `values`: Returns a...
unknown
unknown
[Data structure > Iteration] ## Iteration Iterating over the matrix should be as painless as possible. Taking inspiration from the `Map` native data structure, I opted to add the following methods that return **iterators**: - `indexes`: Returns an iterator that yields the indexes of the matrix. - `values`: Returns a...
[Data structure > Iteration] ## Iteration Iterating over the matrix should be as painless as possible. Taking inspiration from the `Map` native data structure, I opted to add the following methods that return **iterators**: - `indexes`: Returns an iterator that yields the indexes of the matrix. - `values`: Returns a...
code_snippets
8f4dcafc-ca22-4964-bfad-4fc42d25b172
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
5
SemanticChunker@1.0.0
9b34d2f71bbd4d2363ddebbe32f654e135c925bd53bf6ff9a48c6399f781b2f4
[Data structure > Math operations] ## Math operations Matrixes are often used for **mathematical operations**, so, naturally, I added a whole lot of them. I will not go into details about each one of them, but an overview will be provided.
unknown
unknown
[Data structure > Math operations] ## Math operations Matrixes are often used for **mathematical operations**, so, naturally, I added a whole lot of them. I will not go into details about each one of them, but an overview will be provided.
[Data structure > Math operations] ## Math operations Matrixes are often used for **mathematical operations**, so, naturally, I added a whole lot of them. I will not go into details about each one of them, but an overview will be provided.
code_snippets
9c155b1a-bfc2-4e10-ad73-df6023ebb6cf
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
21
SemanticChunker@1.0.0
d028fb6286bcab946a232f731e769fd28b4644ebd7da8a2568978b4a253c167c
[Data structure > Conclusion] ## Conclusion And that's it! A ton of work and code went into this one, but I think it was worth it. I hope you find this class useful in your projects. You can find the **full source code and tests** in the [dedicated GitHub repository](https://github.com/Chalarangelo/matrix-playground/...
unknown
unknown
[Data structure > Conclusion] ## Conclusion And that's it! A ton of work and code went into this one, but I think it was worth it. I hope you find this class useful in your projects. You can find the **full source code and tests** in the [dedicated GitHub repository](https://github.com/Chalarangelo/matrix-playground/...
[Data structure > Conclusion] ## Conclusion And that's it! A ton of work and code went into this one, but I think it was worth it. I hope you find this class useful in your projects. You can find the **full source code and tests** in the [dedicated GitHub repository](https://github.com/Chalarangelo/matrix-playground/...
code_snippets
9ef2fee1-a6ee-4a57-a61e-5efd2d40ea88
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
10
SemanticChunker@1.0.0
25d27e8c29600ae73e78ef3b3e021326608e3dfcfdb67a70d5ab75347c5314e2
[Data structure > Matrix operations] ## Matrix operations Matrix operations are a bit more complex and, quite frankly, I only understand the very basics of them. So, that's what I've implemented so far.
unknown
unknown
[Data structure > Matrix operations] ## Matrix operations Matrix operations are a bit more complex and, quite frankly, I only understand the very basics of them. So, that's what I've implemented so far.
[Data structure > Matrix operations] ## Matrix operations Matrix operations are a bit more complex and, quite frankly, I only understand the very basics of them. So, that's what I've implemented so far.
code_snippets
b1cffdfc-2aa4-4134-8f4a-8ef340610425
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
8
SemanticChunker@1.0.0
e96eeda1bcae171b32202cfbaae32049e33a2eceeb6ffc296389e8ee6201a173
[Math operations > Basic math operations] ``` # [continued: part 1] sum() { return this.reduce((acc, value) => acc + value, 0); } sumPerRow() { return this.data.map(row => row.reduce((acc, value) => acc + value, 0)); } sumPerCol() { const result = Array.from({ length: this.cols }, () => 0); for (let [, j, ...
unknown
unknown
[Math operations > Basic math operations] ``` # [continued: part 1] sum() { return this.reduce((acc, value) => acc + value, 0); } sumPerRow() { return this.data.map(row => row.reduce((acc, value) => acc + value, 0)); } sumPerCol() { const result = Array.from({ length: this.cols }, () => 0); for (let [, j, ...
[Math operations > Basic math operations] ``` # [continued: part 1] sum() { return this.reduce((acc, value) => acc + value, 0); } sumPerRow() { return this.data.map(row => row.reduce((acc, value) => acc + value, 0)); } sumPerCol() { const result = Array.from({ length: this.cols }, () => 0); for (let [, j, ...
code_snippets
c89f6371-6129-4771-9eed-3cc64c3a0177
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
7
SemanticChunker@1.0.0
88380f440bf009902a9e4b01fdb565894134c0d07e81bb16d09ef7fb82cb9a27
[Math operations > Basic math operations] ``` ### Additional math operations Mathematical operations form the bulk of a lot of the functionality I've needed in the past, but basic math doesn't cover everything. Some very **common operations** for working with numbers need to be added, too: - `max` / `maxIndex`/ `ma...
unknown
unknown
[Math operations > Basic math operations] ``` ### Additional math operations Mathematical operations form the bulk of a lot of the functionality I've needed in the past, but basic math doesn't cover everything. Some very **common operations** for working with numbers need to be added, too: - `max` / `maxIndex`/ `ma...
[Math operations > Basic math operations] ``` ### Additional math operations Mathematical operations form the bulk of a lot of the functionality I've needed in the past, but basic math doesn't cover everything. Some very **common operations** for working with numbers need to be added, too: - `max` / `maxIndex`/ `ma...
code_snippets
d399bb83-1b97-4549-94c6-7897f16fe2c5
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
18
SemanticChunker@1.0.0
cbfb0f3825dc67b6838e8161408b0fbae8876f3a21740badb1764d7ae3417d79
[Predicate matching > Filtering] findMatches(callback) { return this.reduce((acc, value, [i, j]) => { if (callback(value, [i, j], this)) acc.push(value); return acc; }, []); } findIndexOfMatches(callback) { return this.reduce((acc, value, [i, j]) => { if (callback(value, [i, j], this)) acc.push([i, j]); retu...
unknown
unknown
[Predicate matching > Filtering] findMatches(callback) { return this.reduce((acc, value, [i, j]) => { if (callback(value, [i, j], this)) acc.push(value); return acc; }, []); } findIndexOfMatches(callback) { return this.reduce((acc, value, [i, j]) => { if (callback(value, [i, j], this)) acc.push([i, j]); retu...
[Predicate matching > Filtering] findMatches(callback) { return this.reduce((acc, value, [i, j]) => { if (callback(value, [i, j], this)) acc.push(value); return acc; }, []); } findIndexOfMatches(callback) { return this.reduce((acc, value, [i, j]) => { if (callback(value, [i, j], this)) acc.push([i, j]); retu...
code_snippets
d4a0b93a-ec3b-4bfa-9e38-94a4074c3783
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
17
SemanticChunker@1.0.0
dd23d1e18107e1c3f18c40f538753809089c517dabd03195251620cabd8cfb31
[Predicate matching > Filtering] ### Filtering **Filtering** a matrix can be done a few different ways. From regular filtering, similar to arrays, to using a **mask matrix/2D array**, there are a few methods we can add: - `mask`: Filter the matrix using a mask matrix. Filtered values are replaces with `0`. - `filter...
unknown
unknown
[Predicate matching > Filtering] ### Filtering **Filtering** a matrix can be done a few different ways. From regular filtering, similar to arrays, to using a **mask matrix/2D array**, there are a few methods we can add: - `mask`: Filter the matrix using a mask matrix. Filtered values are replaces with `0`. - `filter...
[Predicate matching > Filtering] ### Filtering **Filtering** a matrix can be done a few different ways. From regular filtering, similar to arrays, to using a **mask matrix/2D array**, there are a few methods we can add: - `mask`: Filter the matrix using a mask matrix. Filtered values are replaces with `0`. - `filter...
code_snippets
d87dbb3a-5606-4028-ba09-4d316f9b46ce
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
20
SemanticChunker@1.0.0
2adb177a79039428004be8f11400434032a580a5f26e64a73473bffe71c013e2
[Predicate matching > Expanding] ### Expanding Finally, we may want to **expand** a matrix to a larger size, either horizontally or vertically. This is essentially merging the matrix with a new one, filled with `0`s. ```js collapse={10-14} class Matrix { expandRows(rows, fillValue = 0) { const newRows = new Matrix...
unknown
unknown
[Predicate matching > Expanding] ### Expanding Finally, we may want to **expand** a matrix to a larger size, either horizontally or vertically. This is essentially merging the matrix with a new one, filled with `0`s. ```js collapse={10-14} class Matrix { expandRows(rows, fillValue = 0) { const newRows = new Matrix...
[Predicate matching > Expanding] ### Expanding Finally, we may want to **expand** a matrix to a larger size, either horizontally or vertically. This is essentially merging the matrix with a new one, filled with `0`s. ```js collapse={10-14} class Matrix { expandRows(rows, fillValue = 0) { const newRows = new Matrix...
code_snippets
e1ee1a6e-5f69-404f-bea1-e6145845ea4f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
19
SemanticChunker@1.0.0
5fa9fc4b443f7dec884fca0da8b47f513a5a70fd4a703f2b989ba422c21e3601
[Predicate matching > Rotation] ### Rotation **Rotating** the matrix clockwise and counterclockwise is a little more involved, but still pretty straightforward. We don't need any more rotations than just these two, as we can always rotate more than once to get the desired result. ```js collapse={13-19} class Matrix ...
unknown
unknown
[Predicate matching > Rotation] ### Rotation **Rotating** the matrix clockwise and counterclockwise is a little more involved, but still pretty straightforward. We don't need any more rotations than just these two, as we can always rotate more than once to get the desired result. ```js collapse={13-19} class Matrix ...
[Predicate matching > Rotation] ### Rotation **Rotating** the matrix clockwise and counterclockwise is a little more involved, but still pretty straightforward. We don't need any more rotations than just these two, as we can always rotate more than once to get the desired result. ```js collapse={13-19} class Matrix ...
code_snippets
e9abc73e-13c9-4b01-8643-ee8f8ee8bd29
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
0
SemanticChunker@1.0.0
12303bface8606e4e65b5923aa8479451ce192a1e81b358a109f5d65c237964a
--- title: Creating a Matrix data structure in JavaScript shortTitle: Matrix data structure language: javascript tags: [class,array] cover: coffee-branch excerpt: After working with 2D arrays for a while, I decided to create a convenient wrapper for operations. Here's the gist of it. listed: true dateModified: 2025-06-...
unknown
unknown
--- title: Creating a Matrix data structure in JavaScript shortTitle: Matrix data structure language: javascript tags: [class,array] cover: coffee-branch excerpt: After working with 2D arrays for a while, I decided to create a convenient wrapper for operations. Here's the gist of it. listed: true dateModified: 2025-06-...
--- title: Creating a Matrix data structure in JavaScript shortTitle: Matrix data structure language: javascript tags: [class,array] cover: coffee-branch excerpt: After working with 2D arrays for a while, I decided to create a convenient wrapper for operations. Here's the gist of it. listed: true dateModified: 2025-06-...
code_snippets
f01d0601-e5d7-4c4f-87ea-2a7938974c68
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/matrix-data-structure.md
unknown
1c017ade-19cd-43ed-ab68-770587802e7f
1
SemanticChunker@1.0.0
4d7579a10560fbebd58c251ddd317553f1dca643a233867669e09e8da67ddf55
[Data structure] ## Data structure After fooling around with 1D and 2D arrays, it turns out that the naive approach of a **2D array** is the most efficient, given how it affects the performance of operations. On top of the `data` 2D array, we'll also keep track of the number of **rows** (`rows`) and **columns** (`col...
unknown
unknown
[Data structure] ## Data structure After fooling around with 1D and 2D arrays, it turns out that the naive approach of a **2D array** is the most efficient, given how it affects the performance of operations. On top of the `data` 2D array, we'll also keep track of the number of **rows** (`rows`) and **columns** (`col...
[Data structure] ## Data structure After fooling around with 1D and 2D arrays, it turns out that the naive approach of a **2D array** is the most efficient, given how it affects the performance of operations. On top of the `data` 2D array, we'll also keep track of the number of **rows** (`rows`) and **columns** (`col...
code_snippets
145e413c-6539-4329-bacb-4114fdedd337
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
12
SemanticChunker@1.0.0
3e4c65efd70fea6e0ee955b311188745fa3e1c4cf890c4656bd80443824217e5
[Modeling currency > Summary] ## Summary Implementing a **basic structure** for money, currencies and exchange rates is a lot of work, but it's fairly straightforward once you get the basics down. There's plenty of improvements that you can make to this implementation, such as adding more mathematical operations, or ...
unknown
unknown
[Modeling currency > Summary] ## Summary Implementing a **basic structure** for money, currencies and exchange rates is a lot of work, but it's fairly straightforward once you get the basics down. There's plenty of improvements that you can make to this implementation, such as adding more mathematical operations, or ...
[Modeling currency > Summary] ## Summary Implementing a **basic structure** for money, currencies and exchange rates is a lot of work, but it's fairly straightforward once you get the basics down. There's plenty of improvements that you can make to this implementation, such as adding more mathematical operations, or ...
code_snippets
1d8f5998-40c5-4239-af8e-61e2b0bd8bc4
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
13
SemanticChunker@1.0.0
4847b149610f31b98d43107d4ee048aef0a9f90274a60bebd07892cd1b3b59f1
[Modeling currency > Summary] ``` ```js title="Bank.js" class Bank { static defaultBank; exchangeRates; constructor() { this.exchangeRates = new Map(); } setRate(from, to, rate) { const fromCurrency = Currency.wrap(from); const toCurrency = Currency.wrap(to); const exchangeRate = Number.parseFloat(rate); ...
unknown
unknown
[Modeling currency > Summary] ``` ```js title="Bank.js" class Bank { static defaultBank; exchangeRates; constructor() { this.exchangeRates = new Map(); } setRate(from, to, rate) { const fromCurrency = Currency.wrap(from); const toCurrency = Currency.wrap(to); const exchangeRate = Number.parseFloat(rate); ...
[Modeling currency > Summary] ``` ```js title="Bank.js" class Bank { static defaultBank; exchangeRates; constructor() { this.exchangeRates = new Map(); } setRate(from, to, rate) { const fromCurrency = Currency.wrap(from); const toCurrency = Currency.wrap(to); const exchangeRate = Number.parseFloat(rate); ...
code_snippets
24a29dbf-3cfd-46dd-9c98-34f1934f55a8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
1
SemanticChunker@1.0.0
8f54f35c28305c9f14ee5cd72c65701fb2bb5abf3e0287518eefcaa5d0474370
[Modeling currency] ## Modeling currency The first step in modeling any sort of monetary value is to have a **structure for currency**. Luckily, `Intl` has this problem solved for us. You can use `Intl.NumberFormat` with `style: 'currency'` to get a **formatter** for a specific currency. This formatter can then be us...
unknown
unknown
[Modeling currency] ## Modeling currency The first step in modeling any sort of monetary value is to have a **structure for currency**. Luckily, `Intl` has this problem solved for us. You can use `Intl.NumberFormat` with `style: 'currency'` to get a **formatter** for a specific currency. This formatter can then be us...
[Modeling currency] ## Modeling currency The first step in modeling any sort of monetary value is to have a **structure for currency**. Luckily, `Intl` has this problem solved for us. You can use `Intl.NumberFormat` with `style: 'currency'` to get a **formatter** for a specific currency. This formatter can then be us...
code_snippets
2d5c6a3f-ac30-430d-b427-db8091fa6f8f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
4
SemanticChunker@1.0.0
f40a4cb7b358cc584868823beaf96122d3ce0ef0462a8fcd1f146bdb33910c88
[Modeling currency > Modeling money] ## Modeling money A **monetary value** is simply a data structure that contains **a value and a currency**. Implementing a class for that is fairly simple, using the `Currency` class from before. We can then use the currency object to format the value as needed. ```js class Money...
unknown
unknown
[Modeling currency > Modeling money] ## Modeling money A **monetary value** is simply a data structure that contains **a value and a currency**. Implementing a class for that is fairly simple, using the `Currency` class from before. We can then use the currency object to format the value as needed. ```js class Money...
[Modeling currency > Modeling money] ## Modeling money A **monetary value** is simply a data structure that contains **a value and a currency**. Implementing a class for that is fairly simple, using the `Currency` class from before. We can then use the currency object to format the value as needed. ```js class Money...
code_snippets
3e689672-fd10-4f29-9b55-bcd3cec06231
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
5
SemanticChunker@1.0.0
2c62184c6b635a6f4aee25ccfecf2580bb67816280d19343d6f89b63b252319f
[Modeling money > Mathematical operations with money] ### Mathematical operations with money Performing mathematical operations with money is a bit more complex. We need to ensure that the **currency is the same** for both operands. We'll later cover how to handle exchange rates, but for now, we'll focus on the basic...
unknown
unknown
[Modeling money > Mathematical operations with money] ### Mathematical operations with money Performing mathematical operations with money is a bit more complex. We need to ensure that the **currency is the same** for both operands. We'll later cover how to handle exchange rates, but for now, we'll focus on the basic...
[Modeling money > Mathematical operations with money] ### Mathematical operations with money Performing mathematical operations with money is a bit more complex. We need to ensure that the **currency is the same** for both operands. We'll later cover how to handle exchange rates, but for now, we'll focus on the basic...
code_snippets
407dbf1e-30cf-4f60-80f2-10d6243fef7e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
14
SemanticChunker@1.0.0
b1611dd7b75548a0c6ef0d09eb77a7bbf8b9b816d7abfc57ff2b31e66ff4d321
[Modeling currency > Summary] subtract(money) { if (this.currency !== money.currency) money = money.exchangeTo(this.currency); return new Money(this.value - money.value, this.currency); } multiply(num) { return new Money(this.value * num, this.currency); } divide(num) { return new Money(this.value / num, th...
unknown
unknown
[Modeling currency > Summary] subtract(money) { if (this.currency !== money.currency) money = money.exchangeTo(this.currency); return new Money(this.value - money.value, this.currency); } multiply(num) { return new Money(this.value * num, this.currency); } divide(num) { return new Money(this.value / num, th...
[Modeling currency > Summary] subtract(money) { if (this.currency !== money.currency) money = money.exchangeTo(this.currency); return new Money(this.value - money.value, this.currency); } multiply(num) { return new Money(this.value * num, this.currency); } divide(num) { return new Money(this.value / num, th...
code_snippets
457ca43d-38c9-4c13-aea5-f1912ad99805
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
6
SemanticChunker@1.0.0
4d571f4496b2e1d7fe112ced762f7a44eda8925107aaa21c7cc2e49914c9bde2
[Modeling money > Mathematical operations with money] ```js class Money { // ... add(money) { if (this.currency !== money.currency) throw new Error('Cannot add money with different currencies'); return new Money(this.value + money.value, this.currency); } subtract(money) { if (this.currency !== money.currenc...
unknown
unknown
[Modeling money > Mathematical operations with money] ```js class Money { // ... add(money) { if (this.currency !== money.currency) throw new Error('Cannot add money with different currencies'); return new Money(this.value + money.value, this.currency); } subtract(money) { if (this.currency !== money.currenc...
[Modeling money > Mathematical operations with money] ```js class Money { // ... add(money) { if (this.currency !== money.currency) throw new Error('Cannot add money with different currencies'); return new Money(this.value + money.value, this.currency); } subtract(money) { if (this.currency !== money.currenc...
code_snippets
4ff1ba11-5182-4da4-b3ce-d854ff382ad4
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
7
SemanticChunker@1.0.0
9a1999c0aca33a2fc1bddda5319f10bddf35ccd841da6781d691a396699f42a4
[Modeling currency > Modeling exchange rates] ## Modeling exchange rates An **exchange rate** is simply a **ratio between two currencies**. Instead of modeling it as a class, using a **wrapper object** that contains multiple exchange rates provides more utility. We'll be calling this object a `Bank`.
unknown
unknown
[Modeling currency > Modeling exchange rates] ## Modeling exchange rates An **exchange rate** is simply a **ratio between two currencies**. Instead of modeling it as a class, using a **wrapper object** that contains multiple exchange rates provides more utility. We'll be calling this object a `Bank`.
[Modeling currency > Modeling exchange rates] ## Modeling exchange rates An **exchange rate** is simply a **ratio between two currencies**. Instead of modeling it as a class, using a **wrapper object** that contains multiple exchange rates provides more utility. We'll be calling this object a `Bank`.
code_snippets
63193c0a-2675-4221-a308-ba754f00d324
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
2
SemanticChunker@1.0.0
8494a9c1e113740a02fe44c82627485bf09f7be8635e799599c556555b9441d3
[Modeling currency > Setting up currency information] ### Setting up currency information In order to retrieve **all supported currencies**, we can use `Intl.supportedValuesOf()` with `'currency'` as the argument. This will return an array of the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) **currency codes** s...
unknown
unknown
[Modeling currency > Setting up currency information] ### Setting up currency information In order to retrieve **all supported currencies**, we can use `Intl.supportedValuesOf()` with `'currency'` as the argument. This will return an array of the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) **currency codes** s...
[Modeling currency > Setting up currency information] ### Setting up currency information In order to retrieve **all supported currencies**, we can use `Intl.supportedValuesOf()` with `'currency'` as the argument. This will return an array of the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) **currency codes** s...
code_snippets
63fc167a-6f11-41d7-944b-b142d012fdd0
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
11
SemanticChunker@1.0.0
176a367c0f60b1423048bc7ef964a839948665c9e4804439294058a4077d2125
[Modeling exchange rates > Mathematical operations with exchange rates] ### Mathematical operations with exchange rates Having set up exchange rates, we can now perform mathematical operations with money in **different currencies**. We need only check if two `Money` objects are in the same currency before performing ...
unknown
unknown
[Modeling exchange rates > Mathematical operations with exchange rates] ### Mathematical operations with exchange rates Having set up exchange rates, we can now perform mathematical operations with money in **different currencies**. We need only check if two `Money` objects are in the same currency before performing ...
[Modeling exchange rates > Mathematical operations with exchange rates] ### Mathematical operations with exchange rates Having set up exchange rates, we can now perform mathematical operations with money in **different currencies**. We need only check if two `Money` objects are in the same currency before performing ...
code_snippets
65dfe106-a02c-40b9-abec-6b2dfe065d27
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
3
SemanticChunker@1.0.0
a1d5142b0b138a2edd3b7a73483c51cc3267d7fa565153123e5debf0329f6b7d
[Setting up currency information > Retrieving currency objects] ### Retrieving currency objects Having set up all the currency information, we need a way to retrieve it when we need it. Getting the **same currency object for the same currency code** will be important later down the line for comparisons. As we have a ...
unknown
unknown
[Setting up currency information > Retrieving currency objects] ### Retrieving currency objects Having set up all the currency information, we need a way to retrieve it when we need it. Getting the **same currency object for the same currency code** will be important later down the line for comparisons. As we have a ...
[Setting up currency information > Retrieving currency objects] ### Retrieving currency objects Having set up all the currency information, we need a way to retrieve it when we need it. Getting the **same currency object for the same currency code** will be important later down the line for comparisons. As we have a ...
code_snippets
96e6618f-91ba-4458-95cd-89155c8b990d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
10
SemanticChunker@1.0.0
dfe6175776d71c407f6628b35ed0fbf8c9dadabdbe72279fa735445b82725634
[Modeling exchange rates > Making money exchangeable] ### Making money exchangeable Using the `Bank` class to exchange money works, but it's a lot of work to do every time. The more practical scenario would be to **reference** a `Bank` instance from each `Money` object and use it to exchange money. ```js class Money...
unknown
unknown
[Modeling exchange rates > Making money exchangeable] ### Making money exchangeable Using the `Bank` class to exchange money works, but it's a lot of work to do every time. The more practical scenario would be to **reference** a `Bank` instance from each `Money` object and use it to exchange money. ```js class Money...
[Modeling exchange rates > Making money exchangeable] ### Making money exchangeable Using the `Bank` class to exchange money works, but it's a lot of work to do every time. The more practical scenario would be to **reference** a `Bank` instance from each `Money` object and use it to exchange money. ```js class Money...
code_snippets
99020ced-f250-433e-bb88-a26f9f5e6f9f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
0
SemanticChunker@1.0.0
690b36073747e88ac258361ed71fc1e2a90954d0a403db5b7aa5489193698419
--- title: Modeling money, currencies & exchange rates using JavaScript shortTitle: Money, currencies & exchange rates language: javascript tags: [math,class] cover: money excerpt: A deep dive into modeling money, currencies, and exchange rates using JavaScript. listed: true dateModified: 2024-04-24 --- Working with m...
unknown
unknown
--- title: Modeling money, currencies & exchange rates using JavaScript shortTitle: Money, currencies & exchange rates language: javascript tags: [math,class] cover: money excerpt: A deep dive into modeling money, currencies, and exchange rates using JavaScript. listed: true dateModified: 2024-04-24 --- Working with m...
--- title: Modeling money, currencies & exchange rates using JavaScript shortTitle: Money, currencies & exchange rates language: javascript tags: [math,class] cover: money excerpt: A deep dive into modeling money, currencies, and exchange rates using JavaScript. listed: true dateModified: 2024-04-24 --- Working with m...
code_snippets
b6658110-a033-4083-a1a7-099c1446bfda
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
9
SemanticChunker@1.0.0
971af77830aa2be0eb1493f412f7ebf2ef6bdcb59a2218514328c4da84cdb605
[Modeling exchange rates > Converting money] ### Converting money Converting money from one currency to another is a matter of **multiplying the value by the exchange rate**. The responsibility for exchanging money is part of the `Bank` class, as it's the one that holds the exchange rates. ```js class Bank { // ......
unknown
unknown
[Modeling exchange rates > Converting money] ### Converting money Converting money from one currency to another is a matter of **multiplying the value by the exchange rate**. The responsibility for exchanging money is part of the `Bank` class, as it's the one that holds the exchange rates. ```js class Bank { // ......
[Modeling exchange rates > Converting money] ### Converting money Converting money from one currency to another is a matter of **multiplying the value by the exchange rate**. The responsibility for exchanging money is part of the `Bank` class, as it's the one that holds the exchange rates. ```js class Bank { // ......
code_snippets
e6786a3f-4cd4-49f1-8e3a-2252be6fc624
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/modeling-money-currency-exchange-rates.md
unknown
7426b210-befe-4578-863b-66dee32b362d
8
SemanticChunker@1.0.0
bd17d7343d486386365d9c5cdf620cb435b1dcfa01b46e16cd259a385b052986
[Modeling exchange rates > Creating a bank] ### Creating a bank The `Bank` class will contain a `Map` object that maps **currency pairs to exchange rates**. We can add exchange rates using `Map.prototype.set()` and retrieve them using `Map.prototype.get()`. In order to keep things neat and ensure we can pass **either...
unknown
unknown
[Modeling exchange rates > Creating a bank] ### Creating a bank The `Bank` class will contain a `Map` object that maps **currency pairs to exchange rates**. We can add exchange rates using `Map.prototype.set()` and retrieve them using `Map.prototype.get()`. In order to keep things neat and ensure we can pass **either...
[Modeling exchange rates > Creating a bank] ### Creating a bank The `Bank` class will contain a `Map` object that maps **currency pairs to exchange rates**. We can add exchange rates using `Map.prototype.set()` and retrieve them using `Map.prototype.get()`. In order to keep things neat and ensure we can pass **either...
code_snippets
fc2786b4-661f-494d-a5db-1ea7674dfc85
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/node-list-to-array.md
unknown
abf5f4d5-a0e9-49ad-9b3e-705e2e1ec337
0
SemanticChunker@1.0.0
db771d4f699d96588b2814bcb2b2ae9b37d4d92962207aea851b7957e9191c4b
--- title: Convert a NodeList to a JavaScript array shortTitle: NodeList to array language: javascript tags: [browser,array] cover: compass-2 excerpt: Ever needed to convert a `NodeList` to an array in JavaScript? Here's the fastest way to do so. listed: true dateModified: 2024-03-21 --- If you've ever worked with `No...
unknown
unknown
--- title: Convert a NodeList to a JavaScript array shortTitle: NodeList to array language: javascript tags: [browser,array] cover: compass-2 excerpt: Ever needed to convert a `NodeList` to an array in JavaScript? Here's the fastest way to do so. listed: true dateModified: 2024-03-21 --- If you've ever worked with `No...
--- title: Convert a NodeList to a JavaScript array shortTitle: NodeList to array language: javascript tags: [browser,array] cover: compass-2 excerpt: Ever needed to convert a `NodeList` to an array in JavaScript? Here's the fastest way to do so. listed: true dateModified: 2024-03-21 --- If you've ever worked with `No...
code_snippets
17816613-162a-4a3a-824d-7970adbc72f8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/nodejs-static-file-server.md
unknown
a0adf91c-2053-490b-98c3-c549cdb5fecb
4
SemanticChunker@1.0.0
720198c547ac245fd5258bc03e15e44492bfd18de4e2e4325d64a7d03e340b39
[A simple static file server > Omitting the HTML extension] ## Omitting the HTML extension A staple of most websites is the ability to omit the file extension from the URL when requesting an HTML page. It's a small quality of life improvement that users expect and it would be really nice to add to our static file ser...
unknown
unknown
[A simple static file server > Omitting the HTML extension] ## Omitting the HTML extension A staple of most websites is the ability to omit the file extension from the URL when requesting an HTML page. It's a small quality of life improvement that users expect and it would be really nice to add to our static file ser...
[A simple static file server > Omitting the HTML extension] ## Omitting the HTML extension A staple of most websites is the ability to omit the file extension from the URL when requesting an HTML page. It's a small quality of life improvement that users expect and it would be really nice to add to our static file ser...
code_snippets
1d054e71-5839-4c61-b180-32c1b3bc6f62
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/nodejs-static-file-server.md
unknown
a0adf91c-2053-490b-98c3-c549cdb5fecb
6
SemanticChunker@1.0.0
98abea7d73d86b1549641473a8741561f82e5236af9255dc195cb15f523fdbaa
[A simple static file server > Final touches] ```js import { readFile, accessSync, constants } from 'fs'; import { createServer } from 'http'; import { join, normalize, resolve, extname } from 'path'; const port = 8000; const directoryName = './public'; const types = { html: 'text/html', css: 'text/css', js: 'app...
unknown
unknown
[A simple static file server > Final touches] ```js import { readFile, accessSync, constants } from 'fs'; import { createServer } from 'http'; import { join, normalize, resolve, extname } from 'path'; const port = 8000; const directoryName = './public'; const types = { html: 'text/html', css: 'text/css', js: 'app...
[A simple static file server > Final touches] ```js import { readFile, accessSync, constants } from 'fs'; import { createServer } from 'http'; import { join, normalize, resolve, extname } from 'path'; const port = 8000; const directoryName = './public'; const types = { html: 'text/html', css: 'text/css', js: 'app...
code_snippets
3de64e54-f8d9-43d3-83fb-c2d1d0143258
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/nodejs-static-file-server.md
unknown
a0adf91c-2053-490b-98c3-c549cdb5fecb
0
SemanticChunker@1.0.0
705c176a6753f985267b23164083c5408d117d16ff22c2948a79bab43283e0e2
--- title: Create a static file server with Node.js shortTitle: Node.js static file server language: javascript tags: [node,server] cover: man-cup-laptop excerpt: Create your own static file server with Node.js in just 70 lines of code. listed: true dateModified: 2022-06-05 ---
unknown
unknown
--- title: Create a static file server with Node.js shortTitle: Node.js static file server language: javascript tags: [node,server] cover: man-cup-laptop excerpt: Create your own static file server with Node.js in just 70 lines of code. listed: true dateModified: 2022-06-05 ---
--- title: Create a static file server with Node.js shortTitle: Node.js static file server language: javascript tags: [node,server] cover: man-cup-laptop excerpt: Create your own static file server with Node.js in just 70 lines of code. listed: true dateModified: 2022-06-05 ---
code_snippets
487f5b51-8c3a-4d96-b287-7537b4644650
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/nodejs-static-file-server.md
unknown
a0adf91c-2053-490b-98c3-c549cdb5fecb
5
SemanticChunker@1.0.0
1b318abe07faf6cb2b4e8ec40f8de35bfb63019ac724cfaa51614c017dbd4d74
[A simple static file server > Final touches] ## Final touches After implementing all of the above, we can put everything together to create a static file server with all the functionality we need. I'll throw in a couple of finishing touches, such as logging requests to the console and handling a few more file types,...
unknown
unknown
[A simple static file server > Final touches] ## Final touches After implementing all of the above, we can put everything together to create a static file server with all the functionality we need. I'll throw in a couple of finishing touches, such as logging requests to the console and handling a few more file types,...
[A simple static file server > Final touches] ## Final touches After implementing all of the above, we can put everything together to create a static file server with all the functionality we need. I'll throw in a couple of finishing touches, such as logging requests to the console and handling a few more file types,...
code_snippets
5204dc09-13c5-42da-811b-8debd8775e06
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/nodejs-static-file-server.md
unknown
a0adf91c-2053-490b-98c3-c549cdb5fecb
2
SemanticChunker@1.0.0
20c5dfbd39236f53b838d7a9a494722b481c01dfadaa26ba2bc2b85d8cdd413e
[A simple static file server > Modularity] ## Modularity First and foremost, we don't necessarily want to serve files from the same directory as our Node.js server. To address this problem, we would have to change the directory `fs.readFile()` looks for the file in. To accomplish this, we can specify a directory to s...
unknown
unknown
[A simple static file server > Modularity] ## Modularity First and foremost, we don't necessarily want to serve files from the same directory as our Node.js server. To address this problem, we would have to change the directory `fs.readFile()` looks for the file in. To accomplish this, we can specify a directory to s...
[A simple static file server > Modularity] ## Modularity First and foremost, we don't necessarily want to serve files from the same directory as our Node.js server. To address this problem, we would have to change the directory `fs.readFile()` looks for the file in. To accomplish this, we can specify a directory to s...
code_snippets
81f33129-ebc8-444d-b239-b4ea3966bc3e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/nodejs-static-file-server.md
unknown
a0adf91c-2053-490b-98c3-c549cdb5fecb
3
SemanticChunker@1.0.0
326d5c57545571fe6978e42af05a75c44fc7460d2b88d8e581bd52d2d3101fb7
[A simple static file server > Security] ## Security Our next concern is security. Obviously, we don't want users prying around our machine unauthorized. Currently, it's not impossible to get access to files outside of the specified root directory (e.g. `GET /../../../`). To address this, we can use the `path` module...
unknown
unknown
[A simple static file server > Security] ## Security Our next concern is security. Obviously, we don't want users prying around our machine unauthorized. Currently, it's not impossible to get access to files outside of the specified root directory (e.g. `GET /../../../`). To address this, we can use the `path` module...
[A simple static file server > Security] ## Security Our next concern is security. Obviously, we don't want users prying around our machine unauthorized. Currently, it's not impossible to get access to files outside of the specified root directory (e.g. `GET /../../../`). To address this, we can use the `path` module...
code_snippets
eb78251d-a755-471e-b10a-2e429d71589b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/nodejs-static-file-server.md
unknown
a0adf91c-2053-490b-98c3-c549cdb5fecb
1
SemanticChunker@1.0.0
b10c9984ff9d75b9a796d2495b8ac942a3fbae8f3b7d52f5ebd61faa957802a7
[A simple static file server] ## A simple static file server One of the simplest beginner backend projects you can create is a static file server. In its simplest form, a static file server will listen for requests and try to match the requested URL to a file on the local filesystem. Here's a minimal example of that ...
unknown
unknown
[A simple static file server] ## A simple static file server One of the simplest beginner backend projects you can create is a static file server. In its simplest form, a static file server will listen for requests and try to match the requested URL to a file on the local filesystem. Here's a minimal example of that ...
[A simple static file server] ## A simple static file server One of the simplest beginner backend projects you can create is a static file server. In its simplest form, a static file server will listen for requests and try to match the requested URL to a file on the local filesystem. Here's a minimal example of that ...
code_snippets
fbfeea57-24df-4280-b1d5-1c7dd59c5715
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/nodejs-chrome-debugging.md
unknown
51f506e4-e943-4afc-935a-ba650f890723
0
SemanticChunker@1.0.0
3f7b9c1fdb009e96fac476788c7e6ca550c665db14d73f48a7453df09209fa25
--- title: Debugging Node.js using Chrome Developer Tools shortTitle: Debug Node.js with Chrome Developer Tools language: javascript tags: [node,debugging] cover: bug excerpt: Did you know you can use Chrome Developer Tools to debug your Node.js code? Find out how in this short guide. listed: true dateModified: 2021-06...
unknown
unknown
--- title: Debugging Node.js using Chrome Developer Tools shortTitle: Debug Node.js with Chrome Developer Tools language: javascript tags: [node,debugging] cover: bug excerpt: Did you know you can use Chrome Developer Tools to debug your Node.js code? Find out how in this short guide. listed: true dateModified: 2021-06...
--- title: Debugging Node.js using Chrome Developer Tools shortTitle: Debug Node.js with Chrome Developer Tools language: javascript tags: [node,debugging] cover: bug excerpt: Did you know you can use Chrome Developer Tools to debug your Node.js code? Find out how in this short guide. listed: true dateModified: 2021-06...
code_snippets
3277f95d-4146-4ab8-b8ef-975a53e6d078
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/native-data-structures.md
unknown
dec8a246-9181-4d1f-9650-c246406e692f
1
SemanticChunker@1.0.0
4a27b9cd1fb44dd4fe1dcb76cbd231b60515c15764bd4ba5ee86384d94496647
[Arrays] ## Arrays An array is a linear data structure that represents a collection of elements. In JavaScript, arrays don't have a fixed size, while their contents can be of any valid type, even arrays themselves. Arrays are probably the most commonly used data structure and come with a plethora of methods that allo...
unknown
unknown
[Arrays] ## Arrays An array is a linear data structure that represents a collection of elements. In JavaScript, arrays don't have a fixed size, while their contents can be of any valid type, even arrays themselves. Arrays are probably the most commonly used data structure and come with a plethora of methods that allo...
[Arrays] ## Arrays An array is a linear data structure that represents a collection of elements. In JavaScript, arrays don't have a fixed size, while their contents can be of any valid type, even arrays themselves. Arrays are probably the most commonly used data structure and come with a plethora of methods that allo...
code_snippets
4a3da701-956e-4e3c-a99c-5a1afa1cb14d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/native-data-structures.md
unknown
dec8a246-9181-4d1f-9650-c246406e692f
2
SemanticChunker@1.0.0
04bda5c0ea484dd43794f00cfd07cb6e2ffd79e48adb69c9ed96ba74a691263f
[Arrays > Sets] ## Sets A set is a linear data structure that represents an ordered collection of unique values. Sets in JavaScript can store any valid type of value, however each value can only occur once based on value equality checking. ```js const nums = new Set([1, 2, 3]); nums.add(4); nums.add(1); nums.add(5)...
unknown
unknown
[Arrays > Sets] ## Sets A set is a linear data structure that represents an ordered collection of unique values. Sets in JavaScript can store any valid type of value, however each value can only occur once based on value equality checking. ```js const nums = new Set([1, 2, 3]); nums.add(4); nums.add(1); nums.add(5)...
[Arrays > Sets] ## Sets A set is a linear data structure that represents an ordered collection of unique values. Sets in JavaScript can store any valid type of value, however each value can only occur once based on value equality checking. ```js const nums = new Set([1, 2, 3]); nums.add(4); nums.add(1); nums.add(5)...
code_snippets
b2a0c79c-ee6d-4a88-a330-54bb5b1a953c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/native-data-structures.md
unknown
dec8a246-9181-4d1f-9650-c246406e692f
0
SemanticChunker@1.0.0
489cb797c249e4eb5113434f914c9278c11cc6fe72d47e2b8cf2fd84f69e06f8
--- title: Native JavaScript Data Structures shortTitle: Native Data Structures language: javascript tags: [array] cover: purple-flower-macro-2 excerpt: JavaScript provides a handful of native data structures that you can start using in your code right now. listed: true dateModified: 2021-09-05 ---
unknown
unknown
--- title: Native JavaScript Data Structures shortTitle: Native Data Structures language: javascript tags: [array] cover: purple-flower-macro-2 excerpt: JavaScript provides a handful of native data structures that you can start using in your code right now. listed: true dateModified: 2021-09-05 ---
--- title: Native JavaScript Data Structures shortTitle: Native Data Structures language: javascript tags: [array] cover: purple-flower-macro-2 excerpt: JavaScript provides a handful of native data structures that you can start using in your code right now. listed: true dateModified: 2021-09-05 ---
code_snippets
ef516770-7e1c-4337-b768-568eb1794164
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/native-data-structures.md
unknown
dec8a246-9181-4d1f-9650-c246406e692f
3
SemanticChunker@1.0.0
35062abb54ea1af8cea5c38c151718d0187f48325f395e6ae896cb67ad625d1a
[Arrays > Maps] ## Maps A map is an associative data structure that represents a keyed collection of elements. Each key in a JavaScript Map has to be unique and either a primitive value or an object, whereas the values of the map can be of any valid type. ```js const items = new Map([ [1, { name: 'John' }], [2, { ...
unknown
unknown
[Arrays > Maps] ## Maps A map is an associative data structure that represents a keyed collection of elements. Each key in a JavaScript Map has to be unique and either a primitive value or an object, whereas the values of the map can be of any valid type. ```js const items = new Map([ [1, { name: 'John' }], [2, { ...
[Arrays > Maps] ## Maps A map is an associative data structure that represents a keyed collection of elements. Each key in a JavaScript Map has to be unique and either a primitive value or an object, whereas the values of the map can be of any valid type. ```js const items = new Map([ [1, { name: 'John' }], [2, { ...
code_snippets
173493de-6ebd-4b11-8258-1f989cecea52
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/naming-conventions.md
unknown
76d1fb3f-0b2e-484b-b486-85a56f6f8037
5
SemanticChunker@1.0.0
f7e4816b153375eabd824180fe8b77948f580a1d027244c8e92fa5f636d042ba
[Variables > Private] ## Private - Prefix any variable or function with `_` to show intention for it to be private. - As a convention, this will not prevent other parts of the code from accessing it.
unknown
unknown
[Variables > Private] ## Private - Prefix any variable or function with `_` to show intention for it to be private. - As a convention, this will not prevent other parts of the code from accessing it.
[Variables > Private] ## Private - Prefix any variable or function with `_` to show intention for it to be private. - As a convention, this will not prevent other parts of the code from accessing it.
code_snippets
1ee4956b-2269-4818-8c18-2f4cc38f53a2
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/naming-conventions.md
unknown
76d1fb3f-0b2e-484b-b486-85a56f6f8037
0
SemanticChunker@1.0.0
b76ec8d3009eb0bb6868d451520fd8ac1f68349d09905defaf21d661bd2c60ad
--- title: JavaScript naming conventions shortTitle: Naming conventions language: javascript tags: [variable,cheatsheet] cover: naming-conventions excerpt: Naming conventions make code easier to read and understand. Learn how to name your variables in JavaScript with this handy guide. listed: true dateModified: 2021-06...
unknown
unknown
--- title: JavaScript naming conventions shortTitle: Naming conventions language: javascript tags: [variable,cheatsheet] cover: naming-conventions excerpt: Naming conventions make code easier to read and understand. Learn how to name your variables in JavaScript with this handy guide. listed: true dateModified: 2021-06...
--- title: JavaScript naming conventions shortTitle: Naming conventions language: javascript tags: [variable,cheatsheet] cover: naming-conventions excerpt: Naming conventions make code easier to read and understand. Learn how to name your variables in JavaScript with this handy guide. listed: true dateModified: 2021-06...
code_snippets
3cf9e8fb-dfa4-4075-9a85-49381ae9f847
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/naming-conventions.md
unknown
76d1fb3f-0b2e-484b-b486-85a56f6f8037
3
SemanticChunker@1.0.0
6c8fe16bd099fc2da0fae528466cfc492aadf23cf21fff1fc8349dd196625e5d
[Variables > Constant] ## Constant - Names are case-sensitive, lowercase and uppercase are different. - Define constants at the top of your file, function or class. - Sometimes `UPPER_SNAKE_CASE` is used, while other times plain `camelCase`.
unknown
unknown
[Variables > Constant] ## Constant - Names are case-sensitive, lowercase and uppercase are different. - Define constants at the top of your file, function or class. - Sometimes `UPPER_SNAKE_CASE` is used, while other times plain `camelCase`.
[Variables > Constant] ## Constant - Names are case-sensitive, lowercase and uppercase are different. - Define constants at the top of your file, function or class. - Sometimes `UPPER_SNAKE_CASE` is used, while other times plain `camelCase`.
code_snippets
a31f23c6-cae3-4c35-872e-b758211e7a23
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/naming-conventions.md
unknown
76d1fb3f-0b2e-484b-b486-85a56f6f8037
4
SemanticChunker@1.0.0
f7f9df9a84e814a9d3292226f57f266acce9e4b4ce1b9eec09a877324c603a9a
[Variables > Classes] ## Classes - Names are case-sensitive, lowercase and uppercase are different. - Start class names with a capital letter, use `PascalCase` for names. - Use descriptive names, explaining the functionality of the class. - Components, which are used in frontend frameworks follow the same rules.
unknown
unknown
[Variables > Classes] ## Classes - Names are case-sensitive, lowercase and uppercase are different. - Start class names with a capital letter, use `PascalCase` for names. - Use descriptive names, explaining the functionality of the class. - Components, which are used in frontend frameworks follow the same rules.
[Variables > Classes] ## Classes - Names are case-sensitive, lowercase and uppercase are different. - Start class names with a capital letter, use `PascalCase` for names. - Use descriptive names, explaining the functionality of the class. - Components, which are used in frontend frameworks follow the same rules.
code_snippets
b8057c09-d23f-4885-be26-0130ff4e21ee
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/naming-conventions.md
unknown
76d1fb3f-0b2e-484b-b486-85a56f6f8037
1
SemanticChunker@1.0.0
d24ff37ad299820fd7f76dc5d26eb5e78c55673cabdcfd9e4c1fe48db389dc2c
[Variables] ## Variables - Names are case-sensitive, lowercase and uppercase are different. - Start variable names with a letter, use `camelCase` for names. - Variable names should be self-descriptive, describing the stored value. - Boolean variables are usually prefixed with `is` or `has`.
unknown
unknown
[Variables] ## Variables - Names are case-sensitive, lowercase and uppercase are different. - Start variable names with a letter, use `camelCase` for names. - Variable names should be self-descriptive, describing the stored value. - Boolean variables are usually prefixed with `is` or `has`.
[Variables] ## Variables - Names are case-sensitive, lowercase and uppercase are different. - Start variable names with a letter, use `camelCase` for names. - Variable names should be self-descriptive, describing the stored value. - Boolean variables are usually prefixed with `is` or `has`.
code_snippets
d5047299-0ad6-481d-a250-9f8f14fa4899
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/naming-conventions.md
unknown
76d1fb3f-0b2e-484b-b486-85a56f6f8037
2
SemanticChunker@1.0.0
c9f10a2fbc93743109beb4083a57e3c15fcb25d4e0c81eb5274948736613772c
[Variables > Functions] ## Functions - Names are case-sensitive, lowercase and uppercase are different. - Start function names with a letter, use `camelCase` for names. - Use descriptive names, usually verbs in the imperative form. - Common prefixes are `get`, `make`, `apply` etc. - Class methods follow the same rule...
unknown
unknown
[Variables > Functions] ## Functions - Names are case-sensitive, lowercase and uppercase are different. - Start function names with a letter, use `camelCase` for names. - Use descriptive names, usually verbs in the imperative form. - Common prefixes are `get`, `make`, `apply` etc. - Class methods follow the same rule...
[Variables > Functions] ## Functions - Names are case-sensitive, lowercase and uppercase are different. - Start function names with a letter, use `camelCase` for names. - Use descriptive names, usually verbs in the imperative form. - Common prefixes are `get`, `make`, `apply` etc. - Class methods follow the same rule...
code_snippets
1f0dfa9d-9d23-4dc9-b3af-89e9a083cf95
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/myers-diff-algorithm.md
unknown
964b0b9b-6a7d-4dc9-b106-6ce5835f255a
4
SemanticChunker@1.0.0
32b5079d21734c6b549d841d921b5b36d90a1278d58c78ce35482d19093fa340
[Problem statement > Algorithm implementation] ## Algorithm implementation As you can probably tell, this is very similar to the LCS algorithm, but with a few tweaks to handle deletions and insertions. Let's implement this in JavaScript. We'll again make sure it can handle **both strings and arrays** as input. ```js...
unknown
unknown
[Problem statement > Algorithm implementation] ## Algorithm implementation As you can probably tell, this is very similar to the LCS algorithm, but with a few tweaks to handle deletions and insertions. Let's implement this in JavaScript. We'll again make sure it can handle **both strings and arrays** as input. ```js...
[Problem statement > Algorithm implementation] ## Algorithm implementation As you can probably tell, this is very similar to the LCS algorithm, but with a few tweaks to handle deletions and insertions. Let's implement this in JavaScript. We'll again make sure it can handle **both strings and arrays** as input. ```js...
code_snippets
37ccc2ec-f1c9-4190-8d6e-c428370cb1ad
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/myers-diff-algorithm.md
unknown
964b0b9b-6a7d-4dc9-b106-6ce5835f255a
5
SemanticChunker@1.0.0
859c958e20584ee3fb9387b825c555c772cabea3d0b1145a08cf991d864c0fe4
[Problem statement > Visualizing the diff] ## Visualizing the diff This is nice and all, but how would one go about **visualizing it the way Git does**? It's simple, actually! All we need to do is iterate over the `diffs` array and print the values and a prefix based on the operation. While we're at it, we may as wel...
unknown
unknown
[Problem statement > Visualizing the diff] ## Visualizing the diff This is nice and all, but how would one go about **visualizing it the way Git does**? It's simple, actually! All we need to do is iterate over the `diffs` array and print the values and a prefix based on the operation. While we're at it, we may as wel...
[Problem statement > Visualizing the diff] ## Visualizing the diff This is nice and all, but how would one go about **visualizing it the way Git does**? It's simple, actually! All we need to do is iterate over the `diffs` array and print the values and a prefix based on the operation. While we're at it, we may as wel...
code_snippets
3c04d596-2791-4801-a622-5faa08fc29ae
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/myers-diff-algorithm.md
unknown
964b0b9b-6a7d-4dc9-b106-6ce5835f255a
3
SemanticChunker@1.0.0
e9912bab63964b184b037409253e9f1feb14c704524ca9e90c573035dda09278
[Problem statement > Solution explanation] > [!NOTE] > > There are various **optimizations** that can be made to this algorithm, but this article is meant primarily as a **learning resource**. Therefore, I'll keep things nice and simple and leave these optimizations out for now.
unknown
unknown
[Problem statement > Solution explanation] > [!NOTE] > > There are various **optimizations** that can be made to this algorithm, but this article is meant primarily as a **learning resource**. Therefore, I'll keep things nice and simple and leave these optimizations out for now.
[Problem statement > Solution explanation] > [!NOTE] > > There are various **optimizations** that can be made to this algorithm, but this article is meant primarily as a **learning resource**. Therefore, I'll keep things nice and simple and leave these optimizations out for now.
code_snippets
6d94ceea-3510-4429-91d2-4449ddb8c163
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/myers-diff-algorithm.md
unknown
964b0b9b-6a7d-4dc9-b106-6ce5835f255a
2
SemanticChunker@1.0.0
b283b5b66e8bdb8ee3cdec5986882d5eb1e0ada22dcb4d21a3df02c7abe869a3
[Problem statement > Solution explanation] ## Solution explanation Same as the previous problem, we'll use <dfn title='A problem-solving method that breaks down a complex problem into smaller, manageable parts, solves each part, and then optimizes those solutions to find the best overall answer.'>**dynamic programmin...
unknown
unknown
[Problem statement > Solution explanation] ## Solution explanation Same as the previous problem, we'll use <dfn title='A problem-solving method that breaks down a complex problem into smaller, manageable parts, solves each part, and then optimizes those solutions to find the best overall answer.'>**dynamic programmin...
[Problem statement > Solution explanation] ## Solution explanation Same as the previous problem, we'll use <dfn title='A problem-solving method that breaks down a complex problem into smaller, manageable parts, solves each part, and then optimizes those solutions to find the best overall answer.'>**dynamic programmin...
code_snippets
c9d72519-b34f-44d6-bbd5-d09b2408ee88
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/myers-diff-algorithm.md
unknown
964b0b9b-6a7d-4dc9-b106-6ce5835f255a
0
SemanticChunker@1.0.0
dc8de52b22c61f6907c9ad20a6bf6fcb9977a5e5f5c0a459e98397fdd565de19
--- title: How can I calculate the diff between two strings in JavaScript? shortTitle: Myers Diff Algorithm language: javascript tags: [string,array,algorithm] cover: peaches excerpt: Delve deep into the Myers diff algorithm and learn how to calculate the difference between two strings in JavaScript, the way Git does. ...
unknown
unknown
--- title: How can I calculate the diff between two strings in JavaScript? shortTitle: Myers Diff Algorithm language: javascript tags: [string,array,algorithm] cover: peaches excerpt: Delve deep into the Myers diff algorithm and learn how to calculate the difference between two strings in JavaScript, the way Git does. ...
--- title: How can I calculate the diff between two strings in JavaScript? shortTitle: Myers Diff Algorithm language: javascript tags: [string,array,algorithm] cover: peaches excerpt: Delve deep into the Myers diff algorithm and learn how to calculate the difference between two strings in JavaScript, the way Git does. ...
code_snippets
d2a8f688-bf46-42d4-9bb0-6f393c740ec9
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/myers-diff-algorithm.md
unknown
964b0b9b-6a7d-4dc9-b106-6ce5835f255a
1
SemanticChunker@1.0.0
b56304eed73b6080a417d5cb49a368226b4af40dd5436fda6254424b0c58dd9f
[Problem statement] ## Problem statement I find that examples always help clarify things, so let's start with one. Assuming two sequences, `a` and `b`, we want to find the **minimum number of edits** required to convert `a` into `b`. These edits can be either **insertions**, **deletions**, or **replacements**. For th...
unknown
unknown
[Problem statement] ## Problem statement I find that examples always help clarify things, so let's start with one. Assuming two sequences, `a` and `b`, we want to find the **minimum number of edits** required to convert `a` into `b`. These edits can be either **insertions**, **deletions**, or **replacements**. For th...
[Problem statement] ## Problem statement I find that examples always help clarify things, so let's start with one. Assuming two sequences, `a` and `b`, we want to find the **minimum number of edits** required to convert `a` into `b`. These edits can be either **insertions**, **deletions**, or **replacements**. For th...
code_snippets
ea4037a8-fe32-412f-8290-d9db4143318d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/myers-diff-algorithm.md
unknown
964b0b9b-6a7d-4dc9-b106-6ce5835f255a
6
SemanticChunker@1.0.0
553e52ec9241d376899b6ed83cbffda2d5cd6bf38234021f212c3ac9a6d4cff7
[Problem statement > Visualizing the diff] Looks a lot like a Git diff, doesn't it? You can definitely make it even better by adding colors or skipping over long unchanged subsequences, but I'll leave that up to you.
unknown
unknown
[Problem statement > Visualizing the diff] Looks a lot like a Git diff, doesn't it? You can definitely make it even better by adding colors or skipping over long unchanged subsequences, but I'll leave that up to you.
[Problem statement > Visualizing the diff] Looks a lot like a Git diff, doesn't it? You can definitely make it even better by adding colors or skipping over long unchanged subsequences, but I'll leave that up to you.
code_snippets
185572ad-d1c8-4173-8883-002b0f75249b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/most-frequent-array-element.md
unknown
bb5b75a5-851e-4bfe-94b8-6f5bd2aa30ee
2
SemanticChunker@1.0.0
4a87d89b240af941d07a4bbca693feae4ce1863aa5705333bc9e13aa79b3e96d
[Most frequent element in an array of primitives > Most frequent element in an array of objects] ## Most frequent element in an array of objects When dealing with **objects**, you can use the same approach, but you'll need a **mapping function** to extract the value you want to compare. As primitive values can be com...
unknown
unknown
[Most frequent element in an array of primitives > Most frequent element in an array of objects] ## Most frequent element in an array of objects When dealing with **objects**, you can use the same approach, but you'll need a **mapping function** to extract the value you want to compare. As primitive values can be com...
[Most frequent element in an array of primitives > Most frequent element in an array of objects] ## Most frequent element in an array of objects When dealing with **objects**, you can use the same approach, but you'll need a **mapping function** to extract the value you want to compare. As primitive values can be com...
code_snippets