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
029bb2fe-fff1-47a5-a907-bbb7df6c2207
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-initialization.md
unknown
b5cb4141-235c-4aa2-a8fa-0663edf9a738
1
SemanticChunker@1.0.0
05bd7685ef737755c4dee159b9f7542b58b566d128779479542ac3b0040639cf
[Array() constructor] ## Array() constructor The first thing you'd reach for would probably be the `Array()` constructor. Counterintuitively, this is probably the most problematic option to use on its own. While it works for any number of arguments to create an array with the given values, it falls short pretty much ...
unknown
unknown
[Array() constructor] ## Array() constructor The first thing you'd reach for would probably be the `Array()` constructor. Counterintuitively, this is probably the most problematic option to use on its own. While it works for any number of arguments to create an array with the given values, it falls short pretty much ...
[Array() constructor] ## Array() constructor The first thing you'd reach for would probably be the `Array()` constructor. Counterintuitively, this is probably the most problematic option to use on its own. While it works for any number of arguments to create an array with the given values, it falls short pretty much ...
code_snippets
67f87656-97dd-49b5-b3f5-94ebcd522b51
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-initialization.md
unknown
b5cb4141-235c-4aa2-a8fa-0663edf9a738
2
SemanticChunker@1.0.0
37810d2534f4c6105434d5c808cade747ec646f31f915500e046a7af8963d3f5
[Array() constructor > Array.from()] ## Array.from() `Array.from()` is a static method that creates a new, shallow-copied Array instance from an **array-like or iterable object**. It is very useful for converting array-like objects (e.g. `arguments`, `NodeList`) or iterables (e.g. `Set`, `Map`, `Generator`) into actu...
unknown
unknown
[Array() constructor > Array.from()] ## Array.from() `Array.from()` is a static method that creates a new, shallow-copied Array instance from an **array-like or iterable object**. It is very useful for converting array-like objects (e.g. `arguments`, `NodeList`) or iterables (e.g. `Set`, `Map`, `Generator`) into actu...
[Array() constructor > Array.from()] ## Array.from() `Array.from()` is a static method that creates a new, shallow-copied Array instance from an **array-like or iterable object**. It is very useful for converting array-like objects (e.g. `arguments`, `NodeList`) or iterables (e.g. `Set`, `Map`, `Generator`) into actu...
code_snippets
cfccfbc2-3671-4c43-86ab-8d4433eaa67c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-initialization.md
unknown
b5cb4141-235c-4aa2-a8fa-0663edf9a738
0
SemanticChunker@1.0.0
770914e1301ef40ee8664b673a870fb06d162a8badbe8747b39d1e8707b50814
--- title: The many ways to initialize a JavaScript Array shortTitle: Array initialization language: javascript tags: [array] cover: red-mountain-range excerpt: Discover the inner workings of JavaScript arrays and learn about the different ways to initialize them. listed: true dateModified: 2023-06-18 --- Initializing...
unknown
unknown
--- title: The many ways to initialize a JavaScript Array shortTitle: Array initialization language: javascript tags: [array] cover: red-mountain-range excerpt: Discover the inner workings of JavaScript arrays and learn about the different ways to initialize them. listed: true dateModified: 2023-06-18 --- Initializing...
--- title: The many ways to initialize a JavaScript Array shortTitle: Array initialization language: javascript tags: [array] cover: red-mountain-range excerpt: Discover the inner workings of JavaScript arrays and learn about the different ways to initialize them. listed: true dateModified: 2023-06-18 --- Initializing...
code_snippets
d46c2ead-1830-4bdc-8f44-d44100e7054b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-initialization.md
unknown
b5cb4141-235c-4aa2-a8fa-0663edf9a738
4
SemanticChunker@1.0.0
1109b7dc4b656b76e3278b2f527f10bc1d554f248c25843d2b3336f1c6115bdb
[Array() constructor > Array.prototype.map()] ## Array.prototype.map() `Array.from()` allows for a mapping function via a second argument, but a lot of people think it's hard to read. Additionally, there are a few edge cases, where having access to the array itself during mapping can be useful. `Array.prototype.map()...
unknown
unknown
[Array() constructor > Array.prototype.map()] ## Array.prototype.map() `Array.from()` allows for a mapping function via a second argument, but a lot of people think it's hard to read. Additionally, there are a few edge cases, where having access to the array itself during mapping can be useful. `Array.prototype.map()...
[Array() constructor > Array.prototype.map()] ## Array.prototype.map() `Array.from()` allows for a mapping function via a second argument, but a lot of people think it's hard to read. Additionally, there are a few edge cases, where having access to the array itself during mapping can be useful. `Array.prototype.map()...
code_snippets
e1b4e945-5985-4eaa-a254-a775e894f5f1
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-initialization.md
unknown
b5cb4141-235c-4aa2-a8fa-0663edf9a738
3
SemanticChunker@1.0.0
e857cbcd740cb1e2e3dd722f50b69a4bc36cfe5a9e15e422372bca1bbeef83b0
[Array() constructor > Array.prototype.fill()] ## Array.prototype.fill() While `Array.from()` is quite flexible, using a mapping function to fill it with the same value isn't particularly efficient. `Array.prototype.fill()` comes to fill this gap by allowing you to **fill an existing array** with the same value. This...
unknown
unknown
[Array() constructor > Array.prototype.fill()] ## Array.prototype.fill() While `Array.from()` is quite flexible, using a mapping function to fill it with the same value isn't particularly efficient. `Array.prototype.fill()` comes to fill this gap by allowing you to **fill an existing array** with the same value. This...
[Array() constructor > Array.prototype.fill()] ## Array.prototype.fill() While `Array.from()` is quite flexible, using a mapping function to fill it with the same value isn't particularly efficient. `Array.prototype.fill()` comes to fill this gap by allowing you to **fill an existing array** with the same value. This...
code_snippets
e8bb6bad-bd35-4590-82e9-c3f60485a605
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-initialization.md
unknown
b5cb4141-235c-4aa2-a8fa-0663edf9a738
5
SemanticChunker@1.0.0
c76ac68f69885222f11cfc9958af70028a78c300976e389668a2f2cd97a116e0
[Array() constructor > A note on performance] ## A note on performance Performance might be a concern if this sort of operation is very common in your application, but overall none of these options are particularly slow. The `Array()` constructor seems to be the fastest. That being said, if combined with `Array.proto...
unknown
unknown
[Array() constructor > A note on performance] ## A note on performance Performance might be a concern if this sort of operation is very common in your application, but overall none of these options are particularly slow. The `Array()` constructor seems to be the fastest. That being said, if combined with `Array.proto...
[Array() constructor > A note on performance] ## A note on performance Performance might be a concern if this sort of operation is very common in your application, but overall none of these options are particularly slow. The `Array()` constructor seems to be the fastest. That being said, if combined with `Array.proto...
code_snippets
00e17948-a384-4da8-96bc-f65d58a6e5f0
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-includes-any-or-all-values.md
unknown
80936a64-f6b2-4e9e-aff1-81ecb70b7926
0
SemanticChunker@1.0.0
52ee1ca4a18881aeddf7286d07b66c36d634c3d473b649ba5276d44f89c161d5
--- title: Check if a JavaScript array includes any or all values in another array shortTitle: Array includes any or all values language: javascript tags: [array] cover: tomatoes excerpt: Check if any or all the elements in an array are included in another array. listed: true dateModified: 2024-01-13 --- As discussed ...
unknown
unknown
--- title: Check if a JavaScript array includes any or all values in another array shortTitle: Array includes any or all values language: javascript tags: [array] cover: tomatoes excerpt: Check if any or all the elements in an array are included in another array. listed: true dateModified: 2024-01-13 --- As discussed ...
--- title: Check if a JavaScript array includes any or all values in another array shortTitle: Array includes any or all values language: javascript tags: [array] cover: tomatoes excerpt: Check if any or all the elements in an array are included in another array. listed: true dateModified: 2024-01-13 --- As discussed ...
code_snippets
05789320-c564-4577-bad7-50222971ec82
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-includes-any-or-all-values.md
unknown
80936a64-f6b2-4e9e-aff1-81ecb70b7926
2
SemanticChunker@1.0.0
0d872d2f8edd17709e9b30d5d4e21fc2a0f77fe1718c456b2f7d66667b8c4da8
[Check if an array includes any values > Check if an array includes all values] ## Check if an array includes all values Changing the condition to check if all `values` are included in `arr` is simply a matter of swapping `Array.prototype.some()` for `Array.prototype.every()`. The same logic as before applies, except...
unknown
unknown
[Check if an array includes any values > Check if an array includes all values] ## Check if an array includes all values Changing the condition to check if all `values` are included in `arr` is simply a matter of swapping `Array.prototype.some()` for `Array.prototype.every()`. The same logic as before applies, except...
[Check if an array includes any values > Check if an array includes all values] ## Check if an array includes all values Changing the condition to check if all `values` are included in `arr` is simply a matter of swapping `Array.prototype.some()` for `Array.prototype.every()`. The same logic as before applies, except...
code_snippets
a110f6bf-8ad0-4508-a7f9-191e89175eda
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-includes-any-or-all-values.md
unknown
80936a64-f6b2-4e9e-aff1-81ecb70b7926
1
SemanticChunker@1.0.0
5bcf1e4fd242622d67d2346f1d3b433cf0cc5ddfc46ba6f418800e7ca3927eca
[Check if an array includes any values] ## Check if an array includes any values Given an array of `values`, we want to check if at least one of those values is included in another array, `arr`. We can do this by using `Array.prototype.some()` and `Array.prototype.includes()`. This way we can check each value in `val...
unknown
unknown
[Check if an array includes any values] ## Check if an array includes any values Given an array of `values`, we want to check if at least one of those values is included in another array, `arr`. We can do this by using `Array.prototype.some()` and `Array.prototype.includes()`. This way we can check each value in `val...
[Check if an array includes any values] ## Check if an array includes any values Given an array of `values`, we want to check if at least one of those values is included in another array, `arr`. We can do this by using `Array.prototype.some()` and `Array.prototype.includes()`. This way we can check each value in `val...
code_snippets
2da6dd15-fd92-4b74-969f-f9acc9ba4223
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-head-tail.md
unknown
49c9eb81-0d24-4398-9569-d608f58634ba
2
SemanticChunker@1.0.0
425fcd99ecdd11969c4eaf551bf553ddd9d3b0ff00f158d08243acc6c5083d0f
[Destructuring assignment > Individual functions] ## Individual functions Destructuring assignment is nice, but what if you only want to get the head or the tail of an array? You could use destructuring assignment and ignore the variable you don't need, but there are other ways to do this as well.
unknown
unknown
[Destructuring assignment > Individual functions] ## Individual functions Destructuring assignment is nice, but what if you only want to get the head or the tail of an array? You could use destructuring assignment and ignore the variable you don't need, but there are other ways to do this as well.
[Destructuring assignment > Individual functions] ## Individual functions Destructuring assignment is nice, but what if you only want to get the head or the tail of an array? You could use destructuring assignment and ignore the variable you don't need, but there are other ways to do this as well.
code_snippets
74e59515-8129-4f15-b101-87ad77c8eae0
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-head-tail.md
unknown
49c9eb81-0d24-4398-9569-d608f58634ba
3
SemanticChunker@1.0.0
62555c830233edce282eaba25eb04fc89a12eace9bbf693782ef5600e053474f
[Individual functions > Head of an array] ### Head of an array To get the head of an array, you need only access the first element of the array. This can be done using the [bracket notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#Bracket_notation) syntax and the...
unknown
unknown
[Individual functions > Head of an array] ### Head of an array To get the head of an array, you need only access the first element of the array. This can be done using the [bracket notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#Bracket_notation) syntax and the...
[Individual functions > Head of an array] ### Head of an array To get the head of an array, you need only access the first element of the array. This can be done using the [bracket notation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors#Bracket_notation) syntax and the...
code_snippets
76d0c81e-b999-41d8-b972-1451e36b5590
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-head-tail.md
unknown
49c9eb81-0d24-4398-9569-d608f58634ba
4
SemanticChunker@1.0.0
7e37c4d2963993a4828f98f2499c5e0001a3b45c88ec52ddf6fc49f1e6cfaed4
[Individual functions > Tail of an array] ### Tail of an array For the tail of an array, we need to return all elements except for the first one. `Array.prototype.slice()` is great for this, as you can specify a starting index of `1` to get all elements except for the first one. ```js const tail = arr => (arr && arr...
unknown
unknown
[Individual functions > Tail of an array] ### Tail of an array For the tail of an array, we need to return all elements except for the first one. `Array.prototype.slice()` is great for this, as you can specify a starting index of `1` to get all elements except for the first one. ```js const tail = arr => (arr && arr...
[Individual functions > Tail of an array] ### Tail of an array For the tail of an array, we need to return all elements except for the first one. `Array.prototype.slice()` is great for this, as you can specify a starting index of `1` to get all elements except for the first one. ```js const tail = arr => (arr && arr...
code_snippets
9e90eaf3-6caf-4200-8da6-b48f9e164afd
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-head-tail.md
unknown
49c9eb81-0d24-4398-9569-d608f58634ba
1
SemanticChunker@1.0.0
543623aa76e04533796e2fbe4a553bb3f4ace7c46d1975be1ad668579ec316cc
[Destructuring assignment] ## Destructuring assignment The simplest way to get both the head and tail of an array is to simply use the [destructuring assignment](/js/s/destructuring-assignment#array-destructuring) syntax. This allows us to assign the first element of the array to a variable, while the rest of the arr...
unknown
unknown
[Destructuring assignment] ## Destructuring assignment The simplest way to get both the head and tail of an array is to simply use the [destructuring assignment](/js/s/destructuring-assignment#array-destructuring) syntax. This allows us to assign the first element of the array to a variable, while the rest of the arr...
[Destructuring assignment] ## Destructuring assignment The simplest way to get both the head and tail of an array is to simply use the [destructuring assignment](/js/s/destructuring-assignment#array-destructuring) syntax. This allows us to assign the first element of the array to a variable, while the rest of the arr...
code_snippets
fe457fe5-6067-45be-8950-f3f71d6f9279
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-head-tail.md
unknown
49c9eb81-0d24-4398-9569-d608f58634ba
0
SemanticChunker@1.0.0
11898ec58683f9be76bd8b4af3ec3d54f3c724edaf6c851c9a7bbd79d339df63
--- title: Find the head and tail of an array in JavaScript shortTitle: Head and tail of array language: javascript tags: [array] cover: clay-pot-horizon excerpt: Find the head or tail of a JavaScript array without mutating it. listed: true dateModified: 2023-10-08 --- A common operation in any programming language is...
unknown
unknown
--- title: Find the head and tail of an array in JavaScript shortTitle: Head and tail of array language: javascript tags: [array] cover: clay-pot-horizon excerpt: Find the head or tail of a JavaScript array without mutating it. listed: true dateModified: 2023-10-08 --- A common operation in any programming language is...
--- title: Find the head and tail of an array in JavaScript shortTitle: Head and tail of array language: javascript tags: [array] cover: clay-pot-horizon excerpt: Find the head or tail of a JavaScript array without mutating it. listed: true dateModified: 2023-10-08 --- A common operation in any programming language is...
code_snippets
008b681b-33e3-47b3-81d0-8d9f58d9772a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-functions.md
unknown
1c81461c-dc96-4eb0-bd70-e3879394fb94
1
SemanticChunker@1.0.0
3edc6a4c31320728313a4442676ca64c417501e65500dad9ed1a5274816b1e67
[Syntax] ## Syntax In order to understand arrow function syntax, we should start by refactoring a regular function step by step: ```js function square(a) { return a * a; } ``` We can start by refactoring the function declaration to use a variable assignment: ```js const square = function (a) { return a * a; } ``...
unknown
unknown
[Syntax] ## Syntax In order to understand arrow function syntax, we should start by refactoring a regular function step by step: ```js function square(a) { return a * a; } ``` We can start by refactoring the function declaration to use a variable assignment: ```js const square = function (a) { return a * a; } ``...
[Syntax] ## Syntax In order to understand arrow function syntax, we should start by refactoring a regular function step by step: ```js function square(a) { return a * a; } ``` We can start by refactoring the function declaration to use a variable assignment: ```js const square = function (a) { return a * a; } ``...
code_snippets
1f8df104-a5d6-4a8d-82ca-69ba2cd443e8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-functions.md
unknown
1c81461c-dc96-4eb0-bd70-e3879394fb94
2
SemanticChunker@1.0.0
f1bdebb1907b866882cfb19c9d4278271229dbf67f25b0aca302413572767d3c
[Syntax > Execution context] ## Execution context The main difference between arrow functions and regular functions is execution context (i.e. the value of `this`). Technically speaking, most other differences often mentioned either stem from this one or are side effects of it. In a regular function, `this` is dynam...
unknown
unknown
[Syntax > Execution context] ## Execution context The main difference between arrow functions and regular functions is execution context (i.e. the value of `this`). Technically speaking, most other differences often mentioned either stem from this one or are side effects of it. In a regular function, `this` is dynam...
[Syntax > Execution context] ## Execution context The main difference between arrow functions and regular functions is execution context (i.e. the value of `this`). Technically speaking, most other differences often mentioned either stem from this one or are side effects of it. In a regular function, `this` is dynam...
code_snippets
9b0f03e7-bbd7-4dcc-9b94-0f179e2b03bc
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-functions.md
unknown
1c81461c-dc96-4eb0-bd70-e3879394fb94
0
SemanticChunker@1.0.0
320df61395e9e3a6510b45a57cc4e4c83cf1138ea42fce57db9eb4ca85efc37e
--- title: Introduction to arrow functions in JavaScript shortTitle: Arrow functions introduction language: javascript tags: [function] cover: arrow-functions excerpt: JavaScript arrow functions are a very useful tool to learn and master. Here's a complete introduction to everything you need to know. listed: true dateM...
unknown
unknown
--- title: Introduction to arrow functions in JavaScript shortTitle: Arrow functions introduction language: javascript tags: [function] cover: arrow-functions excerpt: JavaScript arrow functions are a very useful tool to learn and master. Here's a complete introduction to everything you need to know. listed: true dateM...
--- title: Introduction to arrow functions in JavaScript shortTitle: Arrow functions introduction language: javascript tags: [function] cover: arrow-functions excerpt: JavaScript arrow functions are a very useful tool to learn and master. Here's a complete introduction to everything you need to know. listed: true dateM...
code_snippets
a593f633-234b-4044-b4e1-cf2c1571eb5a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-functions.md
unknown
1c81461c-dc96-4eb0-bd70-e3879394fb94
3
SemanticChunker@1.0.0
4800b71abfd2a83b822c6becc8427127b3a7876dc8a09b387554bce5b30ee22d
[Syntax > Execution context] As you can see from these examples, there's a difference in how constructors work due to the execution context and how it's resolved. Regular functions can be used as constructors in contrast to arrow functions which will throw a `TypeError` instead. Moreover, arrow functions and regular ...
unknown
unknown
[Syntax > Execution context] As you can see from these examples, there's a difference in how constructors work due to the execution context and how it's resolved. Regular functions can be used as constructors in contrast to arrow functions which will throw a `TypeError` instead. Moreover, arrow functions and regular ...
[Syntax > Execution context] As you can see from these examples, there's a difference in how constructors work due to the execution context and how it's resolved. Regular functions can be used as constructors in contrast to arrow functions which will throw a `TypeError` instead. Moreover, arrow functions and regular ...
code_snippets
febcdd76-051e-47bd-bbe8-482689a06aec
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrays-have-same-contents.md
unknown
71972c9e-928b-4da4-9d97-a8ff0443b77d
0
SemanticChunker@1.0.0
41a3b9b2002ffd6fdd6a57bceac34c7ce4fe4b5d66806b48e05e24b09aff274b
--- title: Check if two JavaScript arrays have same contents shortTitle: Arrays have same contents language: javascript tags: [array] cover: interior-15 excerpt: Learn how to compare the contents of two arrays to see if they contain the same elements regardless of order. listed: true dateModified: 2024-03-04 --- Have ...
unknown
unknown
--- title: Check if two JavaScript arrays have same contents shortTitle: Arrays have same contents language: javascript tags: [array] cover: interior-15 excerpt: Learn how to compare the contents of two arrays to see if they contain the same elements regardless of order. listed: true dateModified: 2024-03-04 --- Have ...
--- title: Check if two JavaScript arrays have same contents shortTitle: Arrays have same contents language: javascript tags: [array] cover: interior-15 excerpt: Learn how to compare the contents of two arrays to see if they contain the same elements regardless of order. listed: true dateModified: 2024-03-04 --- Have ...
code_snippets
4ba6c910-e4e4-411d-80a9-82ef703eab4a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-function-event-listeners.md
unknown
55992f76-63d5-4f90-90db-6756883dceda
1
SemanticChunker@1.0.0
76b7e328a6099537cc462e4aa177226c12a0ab5b253c045272ca8c520a68e0c6
[Arrow functions] ## Arrow functions JavaScript ES6 introduced the concept of arrow functions, a new way to define and write functions. While they might seem like a syntactic sugar on top of regular functions, they have a key difference which lies in the way the `this` context is bound. I strongly suggest you read [U...
unknown
unknown
[Arrow functions] ## Arrow functions JavaScript ES6 introduced the concept of arrow functions, a new way to define and write functions. While they might seem like a syntactic sugar on top of regular functions, they have a key difference which lies in the way the `this` context is bound. I strongly suggest you read [U...
[Arrow functions] ## Arrow functions JavaScript ES6 introduced the concept of arrow functions, a new way to define and write functions. While they might seem like a syntactic sugar on top of regular functions, they have a key difference which lies in the way the `this` context is bound. I strongly suggest you read [U...
code_snippets
5309fdad-c9b5-4bc8-b9c3-92f3448c2a51
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-function-event-listeners.md
unknown
55992f76-63d5-4f90-90db-6756883dceda
0
SemanticChunker@1.0.0
a16f24d82c6130c71bcd9349f0e507cef32d617d16b5882a5c8480e556916964
--- title: Can I use an arrow function as the callback for an event listener in JavaScript? shortTitle: Arrow function as callback for event listener language: javascript tags: [browser,event,function] cover: coffee-float excerpt: Learn the differences between JavaScript ES6 arrow functions and regular functions and ho...
unknown
unknown
--- title: Can I use an arrow function as the callback for an event listener in JavaScript? shortTitle: Arrow function as callback for event listener language: javascript tags: [browser,event,function] cover: coffee-float excerpt: Learn the differences between JavaScript ES6 arrow functions and regular functions and ho...
--- title: Can I use an arrow function as the callback for an event listener in JavaScript? shortTitle: Arrow function as callback for event listener language: javascript tags: [browser,event,function] cover: coffee-float excerpt: Learn the differences between JavaScript ES6 arrow functions and regular functions and ho...
code_snippets
6b3020f2-edd6-4deb-b415-27aea2367dea
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-function-event-listeners.md
unknown
55992f76-63d5-4f90-90db-6756883dceda
2
SemanticChunker@1.0.0
d3b5d218ea7cd34d76dc0817ae04c92e9c9a3d137eebede0c4b6769b26e11a5f
[Arrow functions > Event listener callbacks] ## Event listener callbacks A common task when writing browser-side JavaScript is creating event listeners. For example: ```js const toggleElements = document.querySelectorAll('.toggle'); toggleElements.forEach(el => { el.addEventListener('click', function() { this.clas...
unknown
unknown
[Arrow functions > Event listener callbacks] ## Event listener callbacks A common task when writing browser-side JavaScript is creating event listeners. For example: ```js const toggleElements = document.querySelectorAll('.toggle'); toggleElements.forEach(el => { el.addEventListener('click', function() { this.clas...
[Arrow functions > Event listener callbacks] ## Event listener callbacks A common task when writing browser-side JavaScript is creating event listeners. For example: ```js const toggleElements = document.querySelectorAll('.toggle'); toggleElements.forEach(el => { el.addEventListener('click', function() { this.clas...
code_snippets
ba991609-e1f1-4799-9d8b-8d881ffa4222
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-function-event-listeners.md
unknown
55992f76-63d5-4f90-90db-6756883dceda
3
SemanticChunker@1.0.0
dc33a577ceb7f1061191ee3934e3c5334e6a9cf389f7d9fb5e93b94604fcc2ee
[Arrow functions > Arrow functions as callbacks] ## Arrow functions as callbacks As we have already explained, arrow functions do not have their own bindings for `this`. So what happens if we convert the previous code snippet's callback to an arrow function? Its `this` context refers to the global one, which in this ...
unknown
unknown
[Arrow functions > Arrow functions as callbacks] ## Arrow functions as callbacks As we have already explained, arrow functions do not have their own bindings for `this`. So what happens if we convert the previous code snippet's callback to an arrow function? Its `this` context refers to the global one, which in this ...
[Arrow functions > Arrow functions as callbacks] ## Arrow functions as callbacks As we have already explained, arrow functions do not have their own bindings for `this`. So what happens if we convert the previous code snippet's callback to an arrow function? Its `this` context refers to the global one, which in this ...
code_snippets
84d484b5-82a3-4dad-9eb7-5aada203c908
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrays-of-consecutive-elements.md
unknown
3b83f71d-d099-4a7e-94e7-54efe316cd57
1
SemanticChunker@1.0.0
9cf46e84e1c9c2ffbe43419ff5a554d4856800c2095d2cc93dfc92cd1cc6f673
[Arrays of consecutive elements] ## Arrays of consecutive elements All you need to do is use `Array.prototype.map()` in order to map each element to an array of `n` consecutive elements, using `Array.prototype.slice()` to extract the subarray. In order to make sure no subarrays with fewer than `n` elements are return...
unknown
unknown
[Arrays of consecutive elements] ## Arrays of consecutive elements All you need to do is use `Array.prototype.map()` in order to map each element to an array of `n` consecutive elements, using `Array.prototype.slice()` to extract the subarray. In order to make sure no subarrays with fewer than `n` elements are return...
[Arrays of consecutive elements] ## Arrays of consecutive elements All you need to do is use `Array.prototype.map()` in order to map each element to an array of `n` consecutive elements, using `Array.prototype.slice()` to extract the subarray. In order to make sure no subarrays with fewer than `n` elements are return...
code_snippets
8a2e1954-b86b-4368-ac46-179ebbebdbf8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrays-of-consecutive-elements.md
unknown
3b83f71d-d099-4a7e-94e7-54efe316cd57
2
SemanticChunker@1.0.0
e4ac6723a6744da5abaca6e86f441e3bb72553b01a9b405b25adb77f26399061
[Arrays of consecutive elements > Mapped arrays of consecutive elements] ## Mapped arrays of consecutive elements Subsequently, if you want to **apply a function** to each of the subarrays, you can simply apply the function to each subarray during the mapping process. ```js const apertureMap = (arr, n, fn) => n > a...
unknown
unknown
[Arrays of consecutive elements > Mapped arrays of consecutive elements] ## Mapped arrays of consecutive elements Subsequently, if you want to **apply a function** to each of the subarrays, you can simply apply the function to each subarray during the mapping process. ```js const apertureMap = (arr, n, fn) => n > a...
[Arrays of consecutive elements > Mapped arrays of consecutive elements] ## Mapped arrays of consecutive elements Subsequently, if you want to **apply a function** to each of the subarrays, you can simply apply the function to each subarray during the mapping process. ```js const apertureMap = (arr, n, fn) => n > a...
code_snippets
b6037fbd-c772-47d0-b0ec-b2a0557a74e7
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrays-of-consecutive-elements.md
unknown
3b83f71d-d099-4a7e-94e7-54efe316cd57
0
SemanticChunker@1.0.0
51067aaea90c278d34df39120a88da7c1f6a1bbb03877b2e2ff8f60a73a7c61c
--- title: Generate all consecutive element subarrays from a JavaScript array shortTitle: Consecutive element subarrays language: javascript tags: [array] cover: camera-zoom excerpt: Create an array of `n`-tuples of consecutive elements from a given array. listed: true dateModified: 2024-03-20 --- Getting a single ele...
unknown
unknown
--- title: Generate all consecutive element subarrays from a JavaScript array shortTitle: Consecutive element subarrays language: javascript tags: [array] cover: camera-zoom excerpt: Create an array of `n`-tuples of consecutive elements from a given array. listed: true dateModified: 2024-03-20 --- Getting a single ele...
--- title: Generate all consecutive element subarrays from a JavaScript array shortTitle: Consecutive element subarrays language: javascript tags: [array] cover: camera-zoom excerpt: Create an array of `n`-tuples of consecutive elements from a given array. listed: true dateModified: 2024-03-20 --- Getting a single ele...
code_snippets
0b190f71-47ef-4bee-9bc3-51e56fdadf5d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-regular-function-differences.md
unknown
3338c629-62d4-47f6-8945-c4646c2c988a
1
SemanticChunker@1.0.0
4d92f0dc4ff1c31f894d38a0b8741da046b5ac997c3af418ee7af66c1952f0bf
[Syntax] ## Syntax The first and most obvious difference between arrow functions and regular functions is their syntax. Not only do they look different, but arrow functions also provide an implicit return shorthand and allow parenthesis around a single argument to be omitted. ```js const square = a => a * a; // Equ...
unknown
unknown
[Syntax] ## Syntax The first and most obvious difference between arrow functions and regular functions is their syntax. Not only do they look different, but arrow functions also provide an implicit return shorthand and allow parenthesis around a single argument to be omitted. ```js const square = a => a * a; // Equ...
[Syntax] ## Syntax The first and most obvious difference between arrow functions and regular functions is their syntax. Not only do they look different, but arrow functions also provide an implicit return shorthand and allow parenthesis around a single argument to be omitted. ```js const square = a => a * a; // Equ...
code_snippets
176ae1df-f53a-4e73-bc8f-fa2dd993c1eb
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-regular-function-differences.md
unknown
3338c629-62d4-47f6-8945-c4646c2c988a
6
SemanticChunker@1.0.0
13667594889c1f715c3ca7ed4bfe5198b264227bb5b6a782f1e277f5851d6e9a
[Syntax > Other differences] ## Other differences Finally, there are a couple of other differences that are not as important, but worth mentioning. These include the lack of a `prototype` property in arrow functions, as well as the fact that the `yield` keyword may not be used in an arrow function's body. A consequen...
unknown
unknown
[Syntax > Other differences] ## Other differences Finally, there are a couple of other differences that are not as important, but worth mentioning. These include the lack of a `prototype` property in arrow functions, as well as the fact that the `yield` keyword may not be used in an arrow function's body. A consequen...
[Syntax > Other differences] ## Other differences Finally, there are a couple of other differences that are not as important, but worth mentioning. These include the lack of a `prototype` property in arrow functions, as well as the fact that the `yield` keyword may not be used in an arrow function's body. A consequen...
code_snippets
2856c04d-d0ab-4559-a2dd-c604fa53ee50
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-regular-function-differences.md
unknown
3338c629-62d4-47f6-8945-c4646c2c988a
4
SemanticChunker@1.0.0
3fbd8e7d50ca61980dfcecc9e2102b81b1f362a4ca5cd226b9cb85107d27e78d
[Syntax > Constructors] ## Constructors Regular functions can be used as constructors, using the `new` keyword. Yet another consequence of the lexical resolution of `this` inside arrow functions is that they cannot be used as constructors. Using `new` with an arrow function results in a `TypeError`. ```js function F...
unknown
unknown
[Syntax > Constructors] ## Constructors Regular functions can be used as constructors, using the `new` keyword. Yet another consequence of the lexical resolution of `this` inside arrow functions is that they cannot be used as constructors. Using `new` with an arrow function results in a `TypeError`. ```js function F...
[Syntax > Constructors] ## Constructors Regular functions can be used as constructors, using the `new` keyword. Yet another consequence of the lexical resolution of `this` inside arrow functions is that they cannot be used as constructors. Using `new` with an arrow function results in a `TypeError`. ```js function F...
code_snippets
35a76e5c-bae0-44c2-bc32-f45169946029
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-regular-function-differences.md
unknown
3338c629-62d4-47f6-8945-c4646c2c988a
3
SemanticChunker@1.0.0
c635ded45b3e262b0180d330192ed674f7b3b9dcd1f2b71a4a3b0511e3023f12
[Syntax > Methods] ## Methods Due to arrow functions not defining their own execution context, they're not well-suited for usage as methods. However, thanks to the [Class fields proposal](https://github.com/tc39/proposal-class-fields), arrow functions can be used as methods inside classes, if your environment support...
unknown
unknown
[Syntax > Methods] ## Methods Due to arrow functions not defining their own execution context, they're not well-suited for usage as methods. However, thanks to the [Class fields proposal](https://github.com/tc39/proposal-class-fields), arrow functions can be used as methods inside classes, if your environment support...
[Syntax > Methods] ## Methods Due to arrow functions not defining their own execution context, they're not well-suited for usage as methods. However, thanks to the [Class fields proposal](https://github.com/tc39/proposal-class-fields), arrow functions can be used as methods inside classes, if your environment support...
code_snippets
6b4ccf9c-3829-413d-8f5f-bcbba82e382e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-regular-function-differences.md
unknown
3338c629-62d4-47f6-8945-c4646c2c988a
2
SemanticChunker@1.0.0
6344c37a1d91905c3f79d053b88d1959a6229a5f2706e3378d637a9e530ca608
[Syntax > Execution context] ## Execution context Inside a regular function, execution context (i.e. the value of `this`) is dynamic. This means that the value of `this` depends on how the function was invoked (simple invocation, method invocation, indirect invocation or constructor invocation). On the other hand, an...
unknown
unknown
[Syntax > Execution context] ## Execution context Inside a regular function, execution context (i.e. the value of `this`) is dynamic. This means that the value of `this` depends on how the function was invoked (simple invocation, method invocation, indirect invocation or constructor invocation). On the other hand, an...
[Syntax > Execution context] ## Execution context Inside a regular function, execution context (i.e. the value of `this`) is dynamic. This means that the value of `this` depends on how the function was invoked (simple invocation, method invocation, indirect invocation or constructor invocation). On the other hand, an...
code_snippets
a92a9c98-5a59-4771-bd13-168d0fcfbf6f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-regular-function-differences.md
unknown
3338c629-62d4-47f6-8945-c4646c2c988a
0
SemanticChunker@1.0.0
4d3556e0baab838f9a4be711478fabf744fafab333954363137a5443e852cdb9
--- title: What are the differences between arrow functions and regular functions in JavaScript? shortTitle: Arrow functions vs regular functions language: javascript tags: [function] cover: fallen-leaves excerpt: JavaScript's arrow functions are seemingly the same as regular functions, but there are some important dif...
unknown
unknown
--- title: What are the differences between arrow functions and regular functions in JavaScript? shortTitle: Arrow functions vs regular functions language: javascript tags: [function] cover: fallen-leaves excerpt: JavaScript's arrow functions are seemingly the same as regular functions, but there are some important dif...
--- title: What are the differences between arrow functions and regular functions in JavaScript? shortTitle: Arrow functions vs regular functions language: javascript tags: [function] cover: fallen-leaves excerpt: JavaScript's arrow functions are seemingly the same as regular functions, but there are some important dif...
code_snippets
c0d0acd7-7ad9-4486-bfa6-87715b0687c8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/arrow-regular-function-differences.md
unknown
3338c629-62d4-47f6-8945-c4646c2c988a
5
SemanticChunker@1.0.0
caf3692730d48f1fde5ae88187b5a48fcf1f36e614a6b06be6641619cad1524e
[Syntax > Arguments] ## Arguments Another difference is the binding of the `arguments` object. Unlike regular functions, arrow functions don't have their own `arguments` object. A modern alternative that circumvents this limitation is the usage of rest parameters. ```js function sum() { return arguments[0] + argume...
unknown
unknown
[Syntax > Arguments] ## Arguments Another difference is the binding of the `arguments` object. Unlike regular functions, arrow functions don't have their own `arguments` object. A modern alternative that circumvents this limitation is the usage of rest parameters. ```js function sum() { return arguments[0] + argume...
[Syntax > Arguments] ## Arguments Another difference is the binding of the `arguments` object. Unlike regular functions, arrow functions don't have their own `arguments` object. A modern alternative that circumvents this limitation is the usage of rest parameters. ```js function sum() { return arguments[0] + argume...
code_snippets
0271fcbc-0495-4da6-9105-b0a1930503e8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-stable-sort.md
unknown
6c058881-282d-48d3-9595-e4497f413128
0
SemanticChunker@1.0.0
692b168ae33d6453bc288a294bcb36fb02bbd71cecbacbd429a494870a8bd92d
--- title: Is JavaScript's array sorting stable? shortTitle: Stable array sorting language: javascript tags: [array] cover: horse-sunset excerpt: Understand why JavaScript's built-in array sorting is not stable and how to implement a stable sorting algorithm. listed: true dateModified: 2024-03-21 --- The ECMAScript sp...
unknown
unknown
--- title: Is JavaScript's array sorting stable? shortTitle: Stable array sorting language: javascript tags: [array] cover: horse-sunset excerpt: Understand why JavaScript's built-in array sorting is not stable and how to implement a stable sorting algorithm. listed: true dateModified: 2024-03-21 --- The ECMAScript sp...
--- title: Is JavaScript's array sorting stable? shortTitle: Stable array sorting language: javascript tags: [array] cover: horse-sunset excerpt: Understand why JavaScript's built-in array sorting is not stable and how to implement a stable sorting algorithm. listed: true dateModified: 2024-03-21 --- The ECMAScript sp...
code_snippets
18b072f2-0e68-4fdf-b300-65fe8d6ce90f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-sorting-shorthand.md
unknown
3a7499a0-0d5a-4f3e-80a0-9e47d6a7d9c6
0
SemanticChunker@1.0.0
fb74ac8feca985c51e6466979f424596097c454b0e411191455fd958cc9e502c
--- title: JavaScript array sorting shorthand shortTitle: Array sorting shorthand language: javascript tags: [array] cover: apples excerpt: Learn how to quickly write code to sort JavaScript arrays with this handy one-liner. listed: true dateModified: 2021-06-12 --- When sorting an array of primitive values (e.g. stri...
unknown
unknown
--- title: JavaScript array sorting shorthand shortTitle: Array sorting shorthand language: javascript tags: [array] cover: apples excerpt: Learn how to quickly write code to sort JavaScript arrays with this handy one-liner. listed: true dateModified: 2021-06-12 --- When sorting an array of primitive values (e.g. stri...
--- title: JavaScript array sorting shorthand shortTitle: Array sorting shorthand language: javascript tags: [array] cover: apples excerpt: Learn how to quickly write code to sort JavaScript arrays with this handy one-liner. listed: true dateModified: 2021-06-12 --- When sorting an array of primitive values (e.g. stri...
code_snippets
1fc8cfe3-8772-423d-b3af-70013aa1de05
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-set-operations.md
unknown
c8eaceaa-0b75-46e3-83b6-5b07847a5445
2
SemanticChunker@1.0.0
fcb43c48e0b7cd86f670cec2496798ee135b978714b21b987ac87b4ca70033cc
[Union > Intersection] ## Intersection The **intersection** of two sets is a set containing all **elements that exist in both sets**. In order to calculate it, you can use `Array.prototype.filter()` and `Set.prototype.has()` to filter out all elements that don't exist in the second set. ```js const intersection = (a...
unknown
unknown
[Union > Intersection] ## Intersection The **intersection** of two sets is a set containing all **elements that exist in both sets**. In order to calculate it, you can use `Array.prototype.filter()` and `Set.prototype.has()` to filter out all elements that don't exist in the second set. ```js const intersection = (a...
[Union > Intersection] ## Intersection The **intersection** of two sets is a set containing all **elements that exist in both sets**. In order to calculate it, you can use `Array.prototype.filter()` and `Set.prototype.has()` to filter out all elements that don't exist in the second set. ```js const intersection = (a...
code_snippets
28f16639-ba63-4388-8d1f-380c868a1141
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-set-operations.md
unknown
c8eaceaa-0b75-46e3-83b6-5b07847a5445
5
SemanticChunker@1.0.0
d25d957b255909fe71be77ee567bf743237a0a10d0d0b101edd059fab44ce647
[Union > Application to arrays] ## Application to arrays All of these snippets can be easily applied to **arrays or other iterables** by converting them to `Set` objects and then converting the resulting `Set` objects back to the original type. On top of that, arrays can leverage potential **performance optimization...
unknown
unknown
[Union > Application to arrays] ## Application to arrays All of these snippets can be easily applied to **arrays or other iterables** by converting them to `Set` objects and then converting the resulting `Set` objects back to the original type. On top of that, arrays can leverage potential **performance optimization...
[Union > Application to arrays] ## Application to arrays All of these snippets can be easily applied to **arrays or other iterables** by converting them to `Set` objects and then converting the resulting `Set` objects back to the original type. On top of that, arrays can leverage potential **performance optimization...
code_snippets
4a9547a7-9f77-4d6a-ae16-3502ec3d5353
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-set-operations.md
unknown
c8eaceaa-0b75-46e3-83b6-5b07847a5445
1
SemanticChunker@1.0.0
e992dbef03b28912bb0534cb17e528726245b02df207d253904c8f7727f4ea33
[Union] ## Union The **union** of two sets is a set containing all **elements that exist in any of the two sets at least once**. In order to calculate it, you can use the spread operator (`...`) to convert the `Set` objects to array and create a new `Set` from the resulting array. ```js const union = (a, b) => new S...
unknown
unknown
[Union] ## Union The **union** of two sets is a set containing all **elements that exist in any of the two sets at least once**. In order to calculate it, you can use the spread operator (`...`) to convert the `Set` objects to array and create a new `Set` from the resulting array. ```js const union = (a, b) => new S...
[Union] ## Union The **union** of two sets is a set containing all **elements that exist in any of the two sets at least once**. In order to calculate it, you can use the spread operator (`...`) to convert the `Set` objects to array and create a new `Set` from the resulting array. ```js const union = (a, b) => new S...
code_snippets
5b870dde-414f-4b08-8eae-3b2784ac94d0
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-set-operations.md
unknown
c8eaceaa-0b75-46e3-83b6-5b07847a5445
4
SemanticChunker@1.0.0
c0cf7e514dc0feaf1982d444117808ec77396fec021f0fc40c5e6b10916b2e21
[Union > Symmetric Difference] ## Symmetric Difference The **symmetric difference** of two sets is a set containing all **elements that exist in either of the sets but not in both**. In order to calculate it, you can calculate the difference of each set with the other and then calculate the union of the two results. ...
unknown
unknown
[Union > Symmetric Difference] ## Symmetric Difference The **symmetric difference** of two sets is a set containing all **elements that exist in either of the sets but not in both**. In order to calculate it, you can calculate the difference of each set with the other and then calculate the union of the two results. ...
[Union > Symmetric Difference] ## Symmetric Difference The **symmetric difference** of two sets is a set containing all **elements that exist in either of the sets but not in both**. In order to calculate it, you can calculate the difference of each set with the other and then calculate the union of the two results. ...
code_snippets
d786d0cc-12df-4b55-8184-78451c1b1c71
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-set-operations.md
unknown
c8eaceaa-0b75-46e3-83b6-5b07847a5445
0
SemanticChunker@1.0.0
b3d3254ccb389e7b45a8c2c3e4462975a3ea79ec9c0eb7d29b33de51ada35f24
--- title: Set operations in JavaScript shortTitle: Set operations language: javascript tags: [array] cover: dim-mountains excerpt: Explore how you can apply mathematical set operations to JavaScript `Set` objects and arrays. listed: true dateModified: 2024-01-01 --- Mathematical **set operations** can be easily appli...
unknown
unknown
--- title: Set operations in JavaScript shortTitle: Set operations language: javascript tags: [array] cover: dim-mountains excerpt: Explore how you can apply mathematical set operations to JavaScript `Set` objects and arrays. listed: true dateModified: 2024-01-01 --- Mathematical **set operations** can be easily appli...
--- title: Set operations in JavaScript shortTitle: Set operations language: javascript tags: [array] cover: dim-mountains excerpt: Explore how you can apply mathematical set operations to JavaScript `Set` objects and arrays. listed: true dateModified: 2024-01-01 --- Mathematical **set operations** can be easily appli...
code_snippets
fc8a60b6-33fd-4927-917c-93ad13ebf107
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/array-set-operations.md
unknown
c8eaceaa-0b75-46e3-83b6-5b07847a5445
3
SemanticChunker@1.0.0
13b1ae27447b62467a5b17d63a7e281c75aad0bfc2e7fd36c86d04e7eee0c28d
[Union > Difference] ## Difference The **difference** of two sets is a set containing all **elements that exist in the first set but not in the second set**. In order to calculate it, you can use the same approach as the intersection, but negating the result of `Set.prototype.has()`. ```js const difference = (a, b) ...
unknown
unknown
[Union > Difference] ## Difference The **difference** of two sets is a set containing all **elements that exist in the first set but not in the second set**. In order to calculate it, you can use the same approach as the intersection, but negating the result of `Set.prototype.has()`. ```js const difference = (a, b) ...
[Union > Difference] ## Difference The **difference** of two sets is a set containing all **elements that exist in the first set but not in the second set**. In order to calculate it, you can use the same approach as the intersection, but negating the result of `Set.prototype.has()`. ```js const difference = (a, b) ...
code_snippets
4edc5889-e2b4-4dd4-8365-3d3ffbab5ec5
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-array-loops.md
unknown
d38ec522-bb11-4b1d-9a56-b9304c84eb6f
1
SemanticChunker@1.0.0
dd596caba9c0ab3fd9caf6d6116afff99d5905081e8738664e0b92169dc6f6f3
[For loops] ## For loops @[Quick refresher](/js/s/for-in-for-of-foreach) Combining `async` with a `for` (or a `for...of`) loop is possibly the most straightforward option when performing asynchronous operations over array elements. Using `await` inside a `for` loop will cause the code to **stop and wait** for the as...
unknown
unknown
[For loops] ## For loops @[Quick refresher](/js/s/for-in-for-of-foreach) Combining `async` with a `for` (or a `for...of`) loop is possibly the most straightforward option when performing asynchronous operations over array elements. Using `await` inside a `for` loop will cause the code to **stop and wait** for the as...
[For loops] ## For loops @[Quick refresher](/js/s/for-in-for-of-foreach) Combining `async` with a `for` (or a `for...of`) loop is possibly the most straightforward option when performing asynchronous operations over array elements. Using `await` inside a `for` loop will cause the code to **stop and wait** for the as...
code_snippets
612ba97b-d70c-4f36-881d-190473937c1d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-array-loops.md
unknown
d38ec522-bb11-4b1d-9a56-b9304c84eb6f
0
SemanticChunker@1.0.0
f492735bf01a887f2bf8de2bf90b14bfbaa345e6ad3220beba8d35f2a952e07f
--- title: Asynchronous array loops in JavaScript shortTitle: Asynchronous array loops language: javascript tags: [array,function,promises] cover: sunflowers excerpt: Asynchronously looping over arrays in JavaScript comes with a few caveats you should watch out for. listed: true dateModified: 2021-06-12 --- Asynchrono...
unknown
unknown
--- title: Asynchronous array loops in JavaScript shortTitle: Asynchronous array loops language: javascript tags: [array,function,promises] cover: sunflowers excerpt: Asynchronously looping over arrays in JavaScript comes with a few caveats you should watch out for. listed: true dateModified: 2021-06-12 --- Asynchrono...
--- title: Asynchronous array loops in JavaScript shortTitle: Asynchronous array loops language: javascript tags: [array,function,promises] cover: sunflowers excerpt: Asynchronously looping over arrays in JavaScript comes with a few caveats you should watch out for. listed: true dateModified: 2021-06-12 --- Asynchrono...
code_snippets
82ba497d-88b9-457d-8fd1-f718f548d149
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-array-loops.md
unknown
d38ec522-bb11-4b1d-9a56-b9304c84eb6f
3
SemanticChunker@1.0.0
6cb6c30ee5152e68c1502bc124d3445b6b4764a51e240a841f0f11ffec88088b
[For loops > Array methods] ## Array methods Unfortunately, array methods such as `Array.prototype.forEach()` **do not work** well with `async`/`await`. The only viable solution is to use `Promise.all()` as shown in the previous example. Using an `async` callback with `Array.prototype.forEach()` will result in the re...
unknown
unknown
[For loops > Array methods] ## Array methods Unfortunately, array methods such as `Array.prototype.forEach()` **do not work** well with `async`/`await`. The only viable solution is to use `Promise.all()` as shown in the previous example. Using an `async` callback with `Array.prototype.forEach()` will result in the re...
[For loops > Array methods] ## Array methods Unfortunately, array methods such as `Array.prototype.forEach()` **do not work** well with `async`/`await`. The only viable solution is to use `Promise.all()` as shown in the previous example. Using an `async` callback with `Array.prototype.forEach()` will result in the re...
code_snippets
f69f7ccc-d97e-4170-9965-cba8542a3ff2
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-array-loops.md
unknown
d38ec522-bb11-4b1d-9a56-b9304c84eb6f
2
SemanticChunker@1.0.0
4fbba96fe3f8f5819578f44450b581bf0b4c0de30bb46dfbaef96a85ba7c52b5
[For loops > Promises] ## Promises `Promise.all()` provides another option for asynchronous loops over arrays. The main difference with the previous one is that `Promise.all()` executes **all asynchronous operations in parallel**. This means that promises will execute out of order, which might be an issue in some cas...
unknown
unknown
[For loops > Promises] ## Promises `Promise.all()` provides another option for asynchronous loops over arrays. The main difference with the previous one is that `Promise.all()` executes **all asynchronous operations in parallel**. This means that promises will execute out of order, which might be an issue in some cas...
[For loops > Promises] ## Promises `Promise.all()` provides another option for asynchronous loops over arrays. The main difference with the previous one is that `Promise.all()` executes **all asynchronous operations in parallel**. This means that promises will execute out of order, which might be an issue in some cas...
code_snippets
63d98c9b-2ead-4cd0-ac17-bf8007b5a770
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-cheatsheet.md
unknown
c42f2709-cc71-44b6-ad95-2118c2629791
0
SemanticChunker@1.0.0
bfaa03684fd3914be11bf2b0c65ae60cb5dbd18c0305268bb17ef046f15037b9
--- title: Asynchronous JavaScript Cheat Sheet language: javascript tags: [promises,function,cheatsheet] cover: green-plant excerpt: Learn everything you need to know about promises and asynchronous JavaScript with this handy cheatsheet. listed: true dateModified: 2021-06-12 ---
unknown
unknown
--- title: Asynchronous JavaScript Cheat Sheet language: javascript tags: [promises,function,cheatsheet] cover: green-plant excerpt: Learn everything you need to know about promises and asynchronous JavaScript with this handy cheatsheet. listed: true dateModified: 2021-06-12 ---
--- title: Asynchronous JavaScript Cheat Sheet language: javascript tags: [promises,function,cheatsheet] cover: green-plant excerpt: Learn everything you need to know about promises and asynchronous JavaScript with this handy cheatsheet. listed: true dateModified: 2021-06-12 ---
code_snippets
6ad5e3d6-ee10-41ad-a918-d5a39394f1ef
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-cheatsheet.md
unknown
c42f2709-cc71-44b6-ad95-2118c2629791
1
SemanticChunker@1.0.0
0b7e6b853e89194a34ffb964c14eaaa974d8c3d92b2de07c5e551ed07e1258c7
[Promise basics] ## Promise basics - **Promises** start in a **pending state**, neither fulfilled or rejected. - When the operation is completed, a promise will become **fulfilled with a value**. - If the operation fails, a promise will get **rejected with an error**. @[Quick refresher](/js/promises)
unknown
unknown
[Promise basics] ## Promise basics - **Promises** start in a **pending state**, neither fulfilled or rejected. - When the operation is completed, a promise will become **fulfilled with a value**. - If the operation fails, a promise will get **rejected with an error**. @[Quick refresher](/js/promises)
[Promise basics] ## Promise basics - **Promises** start in a **pending state**, neither fulfilled or rejected. - When the operation is completed, a promise will become **fulfilled with a value**. - If the operation fails, a promise will get **rejected with an error**. @[Quick refresher](/js/promises)
code_snippets
c19e114c-3a95-47bd-94f0-930d0fdf9555
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-cheatsheet.md
unknown
c42f2709-cc71-44b6-ad95-2118c2629791
3
SemanticChunker@1.0.0
684f135db596dbda4e121c3e4c31eb0ca8ed04424ab784ba7f17632c320c6ae5
[Promise basics > Handling promises] ## Handling promises - `Promise.prototype.then()` accepts two optional arguments (`onFulfilled`, `onRejected`). - `Promise.prototype.then()` will call `onFulfilled` once the promise is fulfilled. - `Promise.prototype.then()` will call `onRejected` if the promise is rejected. - `Pr...
unknown
unknown
[Promise basics > Handling promises] ## Handling promises - `Promise.prototype.then()` accepts two optional arguments (`onFulfilled`, `onRejected`). - `Promise.prototype.then()` will call `onFulfilled` once the promise is fulfilled. - `Promise.prototype.then()` will call `onRejected` if the promise is rejected. - `Pr...
[Promise basics > Handling promises] ## Handling promises - `Promise.prototype.then()` accepts two optional arguments (`onFulfilled`, `onRejected`). - `Promise.prototype.then()` will call `onFulfilled` once the promise is fulfilled. - `Promise.prototype.then()` will call `onRejected` if the promise is rejected. - `Pr...
code_snippets
cc8e4148-0277-47c5-a0c7-1e4d74804c6b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-cheatsheet.md
unknown
c42f2709-cc71-44b6-ad95-2118c2629791
2
SemanticChunker@1.0.0
9ae418dd7b7590662cc129f2710341aa30a92f6f7b56fd9c2b5ab873c96effdc
[Promise basics > Creating promises] ## Creating promises - The function passed to the `Promise` constructor will execute synchronously. - Use `resolve()` or `reject()` to create promises from values. - `Promise.resolve(val)` will fulfill the promise with `val`. - `Promise.reject(err)` will reject the promise with `e...
unknown
unknown
[Promise basics > Creating promises] ## Creating promises - The function passed to the `Promise` constructor will execute synchronously. - Use `resolve()` or `reject()` to create promises from values. - `Promise.resolve(val)` will fulfill the promise with `val`. - `Promise.reject(err)` will reject the promise with `e...
[Promise basics > Creating promises] ## Creating promises - The function passed to the `Promise` constructor will execute synchronously. - Use `resolve()` or `reject()` to create promises from values. - `Promise.resolve(val)` will fulfill the promise with `val`. - `Promise.reject(err)` will reject the promise with `e...
code_snippets
f66e58a0-4833-48ce-8a34-8d1ec79389f9
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-cheatsheet.md
unknown
c42f2709-cc71-44b6-ad95-2118c2629791
5
SemanticChunker@1.0.0
6c9024b22e9c5686edf22d7cd773ba56021b69dda7039918d291bec80bce308b
[Promise basics > async/await] ## async/await - Calling an `async` function always results in a promise. - `(async () => value)()` will resolve to `value`. - `(async () => throw err)()` will reject with an error. - `await` waits for a promise to be fulfilled and returns its value. - `await` can only be used in `async...
unknown
unknown
[Promise basics > async/await] ## async/await - Calling an `async` function always results in a promise. - `(async () => value)()` will resolve to `value`. - `(async () => throw err)()` will reject with an error. - `await` waits for a promise to be fulfilled and returns its value. - `await` can only be used in `async...
[Promise basics > async/await] ## async/await - Calling an `async` function always results in a promise. - `(async () => value)()` will resolve to `value`. - `(async () => throw err)()` will reject with an error. - `await` waits for a promise to be fulfilled and returns its value. - `await` can only be used in `async...
code_snippets
fd9767bb-3fe5-42cf-b944-76beca757d6f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-cheatsheet.md
unknown
c42f2709-cc71-44b6-ad95-2118c2629791
4
SemanticChunker@1.0.0
360cd51f6704ea7ab7bb951c7abb3355fc01949b33f00f485a30ddf31d28af52
[Promise basics > Combining promises] ## Combining promises - `Promise.all()` turns an array of promises into a promise of an array. - If any promise is rejected, the error will pass through. - `Promise.race()` passes through the first settled promise. ```js Promise .all([ p1, p2, p3 ]) .then(([ v1, v2, v3 ]) => {...
unknown
unknown
[Promise basics > Combining promises] ## Combining promises - `Promise.all()` turns an array of promises into a promise of an array. - If any promise is rejected, the error will pass through. - `Promise.race()` passes through the first settled promise. ```js Promise .all([ p1, p2, p3 ]) .then(([ v1, v2, v3 ]) => {...
[Promise basics > Combining promises] ## Combining promises - `Promise.all()` turns an array of promises into a promise of an array. - If any promise is rejected, the error will pass through. - `Promise.race()` passes through the first settled promise. ```js Promise .all([ p1, p2, p3 ]) .then(([ v1, v2, v3 ]) => {...
code_snippets
80d977db-3ae5-4292-8013-1244ab848af8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/binomial-coefficient.md
unknown
f7c18d97-044f-43cc-9e17-885e283cce43
0
SemanticChunker@1.0.0
0b6a603cfe2d1dc1ac81e074a0e29987f36d5595f6aae3c66b0dd632bfc9208c
--- title: How can I calculate the binomial coefficient in JavaScript? shortTitle: Binomial coefficient language: javascript tags: [math,algorithm] cover: blue-red-mountain excerpt: Calculate the number of ways to choose k items from n items without repetition and without order. listed: true dateModified: 2024-07-17 --...
unknown
unknown
--- title: How can I calculate the binomial coefficient in JavaScript? shortTitle: Binomial coefficient language: javascript tags: [math,algorithm] cover: blue-red-mountain excerpt: Calculate the number of ways to choose k items from n items without repetition and without order. listed: true dateModified: 2024-07-17 --...
--- title: How can I calculate the binomial coefficient in JavaScript? shortTitle: Binomial coefficient language: javascript tags: [math,algorithm] cover: blue-red-mountain excerpt: Calculate the number of ways to choose k items from n items without repetition and without order. listed: true dateModified: 2024-07-17 --...
code_snippets
4261182e-d568-4e8f-a1d5-a8faed52f22f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/big-o-cheatsheet.md
unknown
8ed73fbc-91dd-4e60-91e3-14e371d6bea6
2
SemanticChunker@1.0.0
431cb918b792db96d7e4352b6b8ef3edd1ea06a0b65c4680aeabac7f5cbc37aa
[Definition > Common Data Structure operations] ## Common Data Structure operations Different data structures have different time complexities for the same operations. For example, a linked list has `O(1)` time complexity for `insert` and `delete` operations, while an array has `O(n)` time complexity for the same ope...
unknown
unknown
[Definition > Common Data Structure operations] ## Common Data Structure operations Different data structures have different time complexities for the same operations. For example, a linked list has `O(1)` time complexity for `insert` and `delete` operations, while an array has `O(n)` time complexity for the same ope...
[Definition > Common Data Structure operations] ## Common Data Structure operations Different data structures have different time complexities for the same operations. For example, a linked list has `O(1)` time complexity for `insert` and `delete` operations, while an array has `O(n)` time complexity for the same ope...
code_snippets
447a2dc6-58ca-4844-bcf5-e4cb2159f35d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/big-o-cheatsheet.md
unknown
8ed73fbc-91dd-4e60-91e3-14e371d6bea6
3
SemanticChunker@1.0.0
347290f5079f069073d9382119097671c61ea516a72ae5785c5397968793cc3c
[Common Data Structure operations > Average time complexity] ### Average time complexity | Data Structure | Access | Search | Insertion | Deletion | | --- | --- | --- | --- | --- | | [**Array**](/js/s/native-data-structures) | Θ(1) | Θ(n) | Θ(n) | Θ(n) | | [**Queue**](/js/s/data-structures-queue) | Θ(n) | Θ(n) | Θ(1)...
unknown
unknown
[Common Data Structure operations > Average time complexity] ### Average time complexity | Data Structure | Access | Search | Insertion | Deletion | | --- | --- | --- | --- | --- | | [**Array**](/js/s/native-data-structures) | Θ(1) | Θ(n) | Θ(n) | Θ(n) | | [**Queue**](/js/s/data-structures-queue) | Θ(n) | Θ(n) | Θ(1)...
[Common Data Structure operations > Average time complexity] ### Average time complexity | Data Structure | Access | Search | Insertion | Deletion | | --- | --- | --- | --- | --- | | [**Array**](/js/s/native-data-structures) | Θ(1) | Θ(n) | Θ(n) | Θ(n) | | [**Queue**](/js/s/data-structures-queue) | Θ(n) | Θ(n) | Θ(1)...
code_snippets
4dd6a10e-6286-448e-ae82-09803e36a322
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/big-o-cheatsheet.md
unknown
8ed73fbc-91dd-4e60-91e3-14e371d6bea6
1
SemanticChunker@1.0.0
e0a5141733c8ed01a67d193bf9eea87f4581c5007a9077f9aa4785a82bcbb4af
[Definition] ## Definition Big-O notation, represents an algorithm's **worst-case complexity**. It uses algebraic terms to describe the complexity of an algorithm, allowing you to measure its efficiency and performance. Below you can find a chart that illustrates Big-O complexity: ![Big-O Complexity Chart](./illustr...
unknown
unknown
[Definition] ## Definition Big-O notation, represents an algorithm's **worst-case complexity**. It uses algebraic terms to describe the complexity of an algorithm, allowing you to measure its efficiency and performance. Below you can find a chart that illustrates Big-O complexity: ![Big-O Complexity Chart](./illustr...
[Definition] ## Definition Big-O notation, represents an algorithm's **worst-case complexity**. It uses algebraic terms to describe the complexity of an algorithm, allowing you to measure its efficiency and performance. Below you can find a chart that illustrates Big-O complexity: ![Big-O Complexity Chart](./illustr...
code_snippets
83a5901f-b228-4b78-8fea-ea06850ab948
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/big-o-cheatsheet.md
unknown
8ed73fbc-91dd-4e60-91e3-14e371d6bea6
0
SemanticChunker@1.0.0
fd02a02a42c62c6dd0a8ed195b31a871ab9b664bd8f3d50f4b00025229c2483d
--- title: Big-O Cheat Sheet language: javascript tags: [algorithm,cheatsheet] cover: light-ring excerpt: Learn everything you need to know about Big-O notation with this handy cheatsheet. listed: true dateModified: 2023-01-08 ---
unknown
unknown
--- title: Big-O Cheat Sheet language: javascript tags: [algorithm,cheatsheet] cover: light-ring excerpt: Learn everything you need to know about Big-O notation with this handy cheatsheet. listed: true dateModified: 2023-01-08 ---
--- title: Big-O Cheat Sheet language: javascript tags: [algorithm,cheatsheet] cover: light-ring excerpt: Learn everything you need to know about Big-O notation with this handy cheatsheet. listed: true dateModified: 2023-01-08 ---
code_snippets
9e576aa0-1853-4662-a7ad-d5105a5150d8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/big-o-cheatsheet.md
unknown
8ed73fbc-91dd-4e60-91e3-14e371d6bea6
4
SemanticChunker@1.0.0
c0982c1b11c70450196fe6c95d7651cc4972158452600aefabfc9d2d27016b4f
[Common Data Structure operations > Worst time complexity] ### Worst time complexity | Data Structure | Access | Search | Insertion | Deletion | | --- | --- | --- | --- | --- | | [**Array**](/js/s/native-data-structures) | O(1) | O(n) | O(n) | O(n) | | [**Queue**](/js/s/data-structures-queue) | O(n) | O(n) | O(1) | O...
unknown
unknown
[Common Data Structure operations > Worst time complexity] ### Worst time complexity | Data Structure | Access | Search | Insertion | Deletion | | --- | --- | --- | --- | --- | | [**Array**](/js/s/native-data-structures) | O(1) | O(n) | O(n) | O(n) | | [**Queue**](/js/s/data-structures-queue) | O(n) | O(n) | O(1) | O...
[Common Data Structure operations > Worst time complexity] ### Worst time complexity | Data Structure | Access | Search | Insertion | Deletion | | --- | --- | --- | --- | --- | | [**Array**](/js/s/native-data-structures) | O(1) | O(n) | O(n) | O(n) | | [**Queue**](/js/s/data-structures-queue) | O(n) | O(n) | O(1) | O...
code_snippets
dac8e503-11c8-48e5-8c81-f509c9fdcbf2
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/big-o-cheatsheet.md
unknown
8ed73fbc-91dd-4e60-91e3-14e371d6bea6
5
SemanticChunker@1.0.0
b3fa972944540ec4c2ef6a99ddd11e2edc6c24caf542aabf15c5b7f59150986c
[Definition > Array sorting algorithms] ## Array sorting algorithms Similar to data structures, different array sorting algorithms have different time complexities. Below you can find the best, average and worst time complexities for the most common array sorting algorithms. | Algorithm | Best | Average | Worst | | ...
unknown
unknown
[Definition > Array sorting algorithms] ## Array sorting algorithms Similar to data structures, different array sorting algorithms have different time complexities. Below you can find the best, average and worst time complexities for the most common array sorting algorithms. | Algorithm | Best | Average | Worst | | ...
[Definition > Array sorting algorithms] ## Array sorting algorithms Similar to data structures, different array sorting algorithms have different time complexities. Below you can find the best, average and worst time complexities for the most common array sorting algorithms. | Algorithm | Best | Average | Worst | | ...
code_snippets
0a095356-b78e-41e2-a9f3-dd3d3b2fb479
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/bifurcate-array.md
unknown
bdded535-9558-4315-b2df-668d172e40bf
2
SemanticChunker@1.0.0
0603be6ed214a8bc5ae6406f9a16674c2a5ad98cfc9d02c6b5de46943f93d273
[Bifurcate array based on value > Bifurcate array based on function] ## Bifurcate array based on function If the values that go into each group are **not known in advance**, you can use a **function** to determine which group each element belongs to. The function will take the current element and its index as argumen...
unknown
unknown
[Bifurcate array based on value > Bifurcate array based on function] ## Bifurcate array based on function If the values that go into each group are **not known in advance**, you can use a **function** to determine which group each element belongs to. The function will take the current element and its index as argumen...
[Bifurcate array based on value > Bifurcate array based on function] ## Bifurcate array based on function If the values that go into each group are **not known in advance**, you can use a **function** to determine which group each element belongs to. The function will take the current element and its index as argumen...
code_snippets
0a0ef1e7-b3e4-4513-a64e-1948e7fa4561
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/bifurcate-array.md
unknown
bdded535-9558-4315-b2df-668d172e40bf
0
SemanticChunker@1.0.0
fc90e24945eef1008eed716a9e5ce82e02e3467a8768eb8e68c32b2e102c40e5
--- title: How can I split a JavaScript array into two groups? shortTitle: Bifurcate array language: javascript tags: [array] cover: canoe excerpt: Learn how to split a JavaScript array into two groups based on a function or an array of values. listed: true dateModified: 2023-10-09 --- Splitting a JavaScript array int...
unknown
unknown
--- title: How can I split a JavaScript array into two groups? shortTitle: Bifurcate array language: javascript tags: [array] cover: canoe excerpt: Learn how to split a JavaScript array into two groups based on a function or an array of values. listed: true dateModified: 2023-10-09 --- Splitting a JavaScript array int...
--- title: How can I split a JavaScript array into two groups? shortTitle: Bifurcate array language: javascript tags: [array] cover: canoe excerpt: Learn how to split a JavaScript array into two groups based on a function or an array of values. listed: true dateModified: 2023-10-09 --- Splitting a JavaScript array int...
code_snippets
46e232e3-cc8a-44a9-9c02-ca79d8d8967d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/bifurcate-array.md
unknown
bdded535-9558-4315-b2df-668d172e40bf
1
SemanticChunker@1.0.0
bc6e2da39b2e4a6fbfadd57ab5e3ee53d445d682f6e5d355154c523d2a290ff5
[Bifurcate array based on value] ## Bifurcate array based on value If the values that go into each group are **known in advance**, you can use an **array of booleans** to determine which group each element belongs to. ```js const bifurcate = (arr, filter) => arr.reduce( (acc, val, i) => { acc[filter[i] ? 0 : 1].p...
unknown
unknown
[Bifurcate array based on value] ## Bifurcate array based on value If the values that go into each group are **known in advance**, you can use an **array of booleans** to determine which group each element belongs to. ```js const bifurcate = (arr, filter) => arr.reduce( (acc, val, i) => { acc[filter[i] ? 0 : 1].p...
[Bifurcate array based on value] ## Bifurcate array based on value If the values that go into each group are **known in advance**, you can use an **array of booleans** to determine which group each element belongs to. ```js const bifurcate = (arr, filter) => arr.reduce( (acc, val, i) => { acc[filter[i] ? 0 : 1].p...
code_snippets
5aec718f-9368-4527-83e8-c7427a945b9b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/binary-number-conversion.md
unknown
8e0b8f64-fe98-48f4-9f43-013ba4c41c84
0
SemanticChunker@1.0.0
d0990b23836d2d6ea65954d20c7fc3bc261a2f7df06ad9818257ee4559b7d736
--- title: Convert between binary and decimal numbers in JavaScript shortTitle: Binary number conversion language: javascript tags: [number] cover: interior-18 excerpt: Binary numbers are a fundamental part of computer science. Learn how to convert between binary and decimal numbers in JavaScript. listed: true dateModi...
unknown
unknown
--- title: Convert between binary and decimal numbers in JavaScript shortTitle: Binary number conversion language: javascript tags: [number] cover: interior-18 excerpt: Binary numbers are a fundamental part of computer science. Learn how to convert between binary and decimal numbers in JavaScript. listed: true dateModi...
--- title: Convert between binary and decimal numbers in JavaScript shortTitle: Binary number conversion language: javascript tags: [number] cover: interior-18 excerpt: Binary numbers are a fundamental part of computer science. Learn how to convert between binary and decimal numbers in JavaScript. listed: true dateModi...
code_snippets
a5e59b2c-33d5-4511-a0a8-b4af3f68b224
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/binary-number-conversion.md
unknown
8e0b8f64-fe98-48f4-9f43-013ba4c41c84
2
SemanticChunker@1.0.0
6171dd60380cbf15aedd35909bb74c375d36b26c7822c4c30ff890565ec3067d
[Binary to decimal > Decimal to binary] ## Decimal to binary To convert a **decimal number** to a binary string, use `Number.prototype.toString()` with a base of `2`. This returns the binary representation of the number as a string. ```js const decimalToBinary = decimal => decimal.toString(2); decimalToBinary(2); /...
unknown
unknown
[Binary to decimal > Decimal to binary] ## Decimal to binary To convert a **decimal number** to a binary string, use `Number.prototype.toString()` with a base of `2`. This returns the binary representation of the number as a string. ```js const decimalToBinary = decimal => decimal.toString(2); decimalToBinary(2); /...
[Binary to decimal > Decimal to binary] ## Decimal to binary To convert a **decimal number** to a binary string, use `Number.prototype.toString()` with a base of `2`. This returns the binary representation of the number as a string. ```js const decimalToBinary = decimal => decimal.toString(2); decimalToBinary(2); /...
code_snippets
bb3cb310-6fb4-4a77-92ad-e1d5de25b7c8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/binary-number-conversion.md
unknown
8e0b8f64-fe98-48f4-9f43-013ba4c41c84
1
SemanticChunker@1.0.0
18a4527d913b25bc986d1a689427efaf8be4228c7d3e4f7c039a0154d37a1185
[Binary to decimal] ## Binary to decimal Given a **binary string**, you can use `Number.parseInt()` with a base of `2` to indicate the string is in binary format and convert it to its **decimal** equivalent. ```js const binaryToDecimal = binary => Number.parseInt(binary, 2); binaryToDecimal('10'); // 2 binaryToDeci...
unknown
unknown
[Binary to decimal] ## Binary to decimal Given a **binary string**, you can use `Number.parseInt()` with a base of `2` to indicate the string is in binary format and convert it to its **decimal** equivalent. ```js const binaryToDecimal = binary => Number.parseInt(binary, 2); binaryToDecimal('10'); // 2 binaryToDeci...
[Binary to decimal] ## Binary to decimal Given a **binary string**, you can use `Number.parseInt()` with a base of `2` to indicate the string is in binary format and convert it to its **decimal** equivalent. ```js const binaryToDecimal = binary => Number.parseInt(binary, 2); binaryToDecimal('10'); // 2 binaryToDeci...
code_snippets
5df40d9f-9ec9-4a5d-a560-98933680ae45
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/binary-search-insert-index-sorted-number-array.md
unknown
5d2e1082-059f-463f-992c-d4b3ecb09a7a
1
SemanticChunker@1.0.0
f14992661505cf93d2230e0bd3f0e0938e600aed40b72fd40cb6f394446ae576
```js {12} const searchInsert = (arr, item) => { let l = 0, r = arr.length - 1; while (l <= r) { const mid = Math.floor((l + r) / 2); if (arr[mid] === item) return mid; if (arr[mid] < item) l = mid + 1; else r = mid - 1; } return l; }; searchInsert([1, 3, 5, 6], 5); // 2 searchInsert([1, 3, 5, 6], 2); // 1 ...
unknown
unknown
```js {12} const searchInsert = (arr, item) => { let l = 0, r = arr.length - 1; while (l <= r) { const mid = Math.floor((l + r) / 2); if (arr[mid] === item) return mid; if (arr[mid] < item) l = mid + 1; else r = mid - 1; } return l; }; searchInsert([1, 3, 5, 6], 5); // 2 searchInsert([1, 3, 5, 6], 2); // 1 ...
```js {12} const searchInsert = (arr, item) => { let l = 0, r = arr.length - 1; while (l <= r) { const mid = Math.floor((l + r) / 2); if (arr[mid] === item) return mid; if (arr[mid] < item) l = mid + 1; else r = mid - 1; } return l; }; searchInsert([1, 3, 5, 6], 5); // 2 searchInsert([1, 3, 5, 6], 2); // 1 ...
code_snippets
aaeaab14-055c-4193-be64-05de54080694
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/binary-search-insert-index-sorted-number-array.md
unknown
5d2e1082-059f-463f-992c-d4b3ecb09a7a
0
SemanticChunker@1.0.0
c3798ecb029665ec2dd32ee21593c98616975422dd207059e8d4326b4d869315
--- title: Using binary search to find the index to insert a number in a sorted JavaScript array shortTitle: Binary search insertion index language: javascript tags: [algorithm,array,math] cover: tokyo-tower excerpt: Combining techniques presented in the past, we can solve a more complex problem with stellar performanc...
unknown
unknown
--- title: Using binary search to find the index to insert a number in a sorted JavaScript array shortTitle: Binary search insertion index language: javascript tags: [algorithm,array,math] cover: tokyo-tower excerpt: Combining techniques presented in the past, we can solve a more complex problem with stellar performanc...
--- title: Using binary search to find the index to insert a number in a sorted JavaScript array shortTitle: Binary search insertion index language: javascript tags: [algorithm,array,math] cover: tokyo-tower excerpt: Combining techniques presented in the past, we can solve a more complex problem with stellar performanc...
code_snippets
2be7cc0d-8110-49ae-a096-65c7831d5ae3
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/attempt-invoking-function.md
unknown
eebe3522-deba-4940-8da4-c664348b1520
0
SemanticChunker@1.0.0
1b7815ff28456c326e5cf303890d4077e33fa2b7ebf682d21ab11d5df04db841
--- title: Attempt invoking a JavaScript function shortTitle: Attempt invoking function language: javascript tags: [function] cover: spanish-resort excerpt: Wrap a function call in a `try...catch` block to handle errors and return the result or the caught error object. listed: true dateModified: 2024-07-27 --- While `...
unknown
unknown
--- title: Attempt invoking a JavaScript function shortTitle: Attempt invoking function language: javascript tags: [function] cover: spanish-resort excerpt: Wrap a function call in a `try...catch` block to handle errors and return the result or the caught error object. listed: true dateModified: 2024-07-27 --- While `...
--- title: Attempt invoking a JavaScript function shortTitle: Attempt invoking function language: javascript tags: [function] cover: spanish-resort excerpt: Wrap a function call in a `try...catch` block to handle errors and return the result or the caught error object. listed: true dateModified: 2024-07-27 --- While `...
code_snippets
450632d5-da65-46eb-b67a-3aff71362102
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/best-time-to-buy-and-sell-stock.md
unknown
ddacd8a3-8729-43c1-ad0b-be0136b647e0
1
SemanticChunker@1.0.0
782ac17cf645419f44d778bf1e97ee714d44ea91524f3bfa19c37273d25ad0cb
[Maximum subarray approach] ## Maximum subarray approach Naturally, this felt very similar to the **maximum subarray** problem, which I've tackled in the past. In fact, one very simple solution involves using the code previously written for said problem with a couple of additional steps. ```js const maxSubarray = ar...
unknown
unknown
[Maximum subarray approach] ## Maximum subarray approach Naturally, this felt very similar to the **maximum subarray** problem, which I've tackled in the past. In fact, one very simple solution involves using the code previously written for said problem with a couple of additional steps. ```js const maxSubarray = ar...
[Maximum subarray approach] ## Maximum subarray approach Naturally, this felt very similar to the **maximum subarray** problem, which I've tackled in the past. In fact, one very simple solution involves using the code previously written for said problem with a couple of additional steps. ```js const maxSubarray = ar...
code_snippets
4a03b562-54e1-458f-be14-1d9ec89209e8
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/best-time-to-buy-and-sell-stock.md
unknown
ddacd8a3-8729-43c1-ad0b-be0136b647e0
3
SemanticChunker@1.0.0
43e76532bf7b6c397ec86cd1f5cfc18b0e2daa1ce21062d6e8922617dbe8f3d5
[Maximum subarray approach > Conclusion] ## Conclusion A seemingly simple problem can often be solved in multiple ways, each with its own trade-offs. While there's nothing wrong with using familiar tools and building on top of previous solutions, it's always worth exploring more efficient approaches. In this case, th...
unknown
unknown
[Maximum subarray approach > Conclusion] ## Conclusion A seemingly simple problem can often be solved in multiple ways, each with its own trade-offs. While there's nothing wrong with using familiar tools and building on top of previous solutions, it's always worth exploring more efficient approaches. In this case, th...
[Maximum subarray approach > Conclusion] ## Conclusion A seemingly simple problem can often be solved in multiple ways, each with its own trade-offs. While there's nothing wrong with using familiar tools and building on top of previous solutions, it's always worth exploring more efficient approaches. In this case, th...
code_snippets
85120400-6ac4-4adf-912a-b257d2b86e03
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/best-time-to-buy-and-sell-stock.md
unknown
ddacd8a3-8729-43c1-ad0b-be0136b647e0
2
SemanticChunker@1.0.0
206d3bf789f7a86eeafcf71547f4d55b71d188d8973af2081631bec42915d33b
[Maximum subarray approach > Single pass approach] ## Single pass approach Instead of creating a new array and using the maximum subarray approach, we can solve the problem in a **single pass** through the prices array. The idea is to **keep track of the minimum price seen so far** and calculate the profit at each st...
unknown
unknown
[Maximum subarray approach > Single pass approach] ## Single pass approach Instead of creating a new array and using the maximum subarray approach, we can solve the problem in a **single pass** through the prices array. The idea is to **keep track of the minimum price seen so far** and calculate the profit at each st...
[Maximum subarray approach > Single pass approach] ## Single pass approach Instead of creating a new array and using the maximum subarray approach, we can solve the problem in a **single pass** through the prices array. The idea is to **keep track of the minimum price seen so far** and calculate the profit at each st...
code_snippets
b22f97c1-2bb1-4ac2-9b89-f087389b2fa4
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/best-time-to-buy-and-sell-stock.md
unknown
ddacd8a3-8729-43c1-ad0b-be0136b647e0
0
SemanticChunker@1.0.0
b88b4ab93d43d3bebcc6db87a6727788c817cb22ce9d8cd0ee7151d6972f1b71
--- title: Best Time to Buy and Sell Stock JavaScript Solution shortTitle: Best Time to Buy and Sell Stock language: javascript tags: [algorithm,math,array] cover: workhard-laptop excerpt: Have you tried solving "Best Time to Buy and Sell Stock" on LeetCode? Let's take a couple of approaches to tackle it in JavaScript....
unknown
unknown
--- title: Best Time to Buy and Sell Stock JavaScript Solution shortTitle: Best Time to Buy and Sell Stock language: javascript tags: [algorithm,math,array] cover: workhard-laptop excerpt: Have you tried solving "Best Time to Buy and Sell Stock" on LeetCode? Let's take a couple of approaches to tackle it in JavaScript....
--- title: Best Time to Buy and Sell Stock JavaScript Solution shortTitle: Best Time to Buy and Sell Stock language: javascript tags: [algorithm,math,array] cover: workhard-laptop excerpt: Have you tried solving "Best Time to Buy and Sell Stock" on LeetCode? Let's take a couple of approaches to tackle it in JavaScript....
code_snippets
cfad5413-8171-495f-bbd8-7ae8399452b7
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/binary-search.md
unknown
b5485656-b330-45e2-ac0d-948f6dfb5e67
0
SemanticChunker@1.0.0
852b28a1de273096bc87cfda708b46941fdd77ec5346b7a7428c0b5f496af380
--- title: Binary search in a sorted JavaScript array shortTitle: Binary search language: javascript tags: [algorithm,array] cover: zen-indoors excerpt: Use the binary search algorithm to find the index of a given element in a sorted array. listed: true dateModified: 2024-07-20 --- The [binary search algorithm](https:...
unknown
unknown
--- title: Binary search in a sorted JavaScript array shortTitle: Binary search language: javascript tags: [algorithm,array] cover: zen-indoors excerpt: Use the binary search algorithm to find the index of a given element in a sorted array. listed: true dateModified: 2024-07-20 --- The [binary search algorithm](https:...
--- title: Binary search in a sorted JavaScript array shortTitle: Binary search language: javascript tags: [algorithm,array] cover: zen-indoors excerpt: Use the binary search algorithm to find the index of a given element in a sorted array. listed: true dateModified: 2024-07-20 --- The [binary search algorithm](https:...
code_snippets
25688b12-317d-42aa-a731-d90565b68003
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-function-composition.md
unknown
dc885de4-2e1a-4d1b-987c-20d146acd1a6
1
SemanticChunker@1.0.0
c12af3f215dba52b628e5fcef9e2358c9b1072dbb30520c4355ffaba73ea25a8
[Pipe async functions] ## Pipe async functions **Left-to-right** function composition for asynchronous functions can be achieved by using `Array.prototype.reduce()` and the spread operator (`...`) to perform function composition using `Promise.prototype.then()`. The functions can return a combination of normal value...
unknown
unknown
[Pipe async functions] ## Pipe async functions **Left-to-right** function composition for asynchronous functions can be achieved by using `Array.prototype.reduce()` and the spread operator (`...`) to perform function composition using `Promise.prototype.then()`. The functions can return a combination of normal value...
[Pipe async functions] ## Pipe async functions **Left-to-right** function composition for asynchronous functions can be achieved by using `Array.prototype.reduce()` and the spread operator (`...`) to perform function composition using `Promise.prototype.then()`. The functions can return a combination of normal value...
code_snippets
4d90588d-b2f1-43c1-9684-f756c3a6dfbb
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-function-composition.md
unknown
dc885de4-2e1a-4d1b-987c-20d146acd1a6
0
SemanticChunker@1.0.0
8980e2724e463860a3e03008af49339129bf69c45414c058afd571eee0aeb25a
--- title: Asynchronous function composition in JavaScript shortTitle: Async function composition language: javascript tags: [promises,function] cover: new-york-skyline excerpt: Learn how to perform function composition for asynchronous functions. listed: true dateModified: 2024-07-27 --- If you're familiar with [func...
unknown
unknown
--- title: Asynchronous function composition in JavaScript shortTitle: Async function composition language: javascript tags: [promises,function] cover: new-york-skyline excerpt: Learn how to perform function composition for asynchronous functions. listed: true dateModified: 2024-07-27 --- If you're familiar with [func...
--- title: Asynchronous function composition in JavaScript shortTitle: Async function composition language: javascript tags: [promises,function] cover: new-york-skyline excerpt: Learn how to perform function composition for asynchronous functions. listed: true dateModified: 2024-07-27 --- If you're familiar with [func...
code_snippets
6399d6d8-9e3a-49ab-bf28-e5fe2e179b85
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/async-function-composition.md
unknown
dc885de4-2e1a-4d1b-987c-20d146acd1a6
2
SemanticChunker@1.0.0
8fe4d9b174757d48d45adde7f30487fa3c6d4824ef616677f62d392f98cf7fdc
[Pipe async functions > Compose async functions] ## Compose async functions **Right-to-left** function compositions for asynchronous functions can be achieved by using the lesser-used `Array.prototype.reduceRight()` in place of `Array.prototype.reduce()`. The rest of the implementation is the same. ```js const compo...
unknown
unknown
[Pipe async functions > Compose async functions] ## Compose async functions **Right-to-left** function compositions for asynchronous functions can be achieved by using the lesser-used `Array.prototype.reduceRight()` in place of `Array.prototype.reduce()`. The rest of the implementation is the same. ```js const compo...
[Pipe async functions > Compose async functions] ## Compose async functions **Right-to-left** function compositions for asynchronous functions can be achieved by using the lesser-used `Array.prototype.reduceRight()` in place of `Array.prototype.reduce()`. The rest of the implementation is the same. ```js const compo...
code_snippets
194399c7-3eb4-4c23-b035-11d709c76b92
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/await-timeout.md
unknown
a3263d5d-cac8-4f66-a9d3-0f1a9829bae7
2
SemanticChunker@1.0.0
22b2ac780ce540732f38b5b98070c48a45bd56598bd5641bb184e8988cd0adf3
[A simple timeout promise > Adding a timeout to another promise] ## Adding a timeout to another promise In order to add a timeout to another promise, however, there are two additional needs this utility has to satisfy. The first one is allowing the timeout promise to **reject** instead of resolving when provided a re...
unknown
unknown
[A simple timeout promise > Adding a timeout to another promise] ## Adding a timeout to another promise In order to add a timeout to another promise, however, there are two additional needs this utility has to satisfy. The first one is allowing the timeout promise to **reject** instead of resolving when provided a re...
[A simple timeout promise > Adding a timeout to another promise] ## Adding a timeout to another promise In order to add a timeout to another promise, however, there are two additional needs this utility has to satisfy. The first one is allowing the timeout promise to **reject** instead of resolving when provided a re...
code_snippets
a50e2f9e-5e5d-48f9-888b-3e7c6293c58f
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/await-timeout.md
unknown
a3263d5d-cac8-4f66-a9d3-0f1a9829bae7
3
SemanticChunker@1.0.0
e678593993fcd8b1a9cf02a8df9e95f6844c15eb3e6420edb978c47c2091dfc7
[A simple timeout promise > A more advanced timeout utility] ## A more advanced timeout utility This implementation definitely works, but we can take it a couple steps further. An obvious improvement is the addition of a way to **clear a timeout**, which requires storing the ids of any active timeouts. This, along wi...
unknown
unknown
[A simple timeout promise > A more advanced timeout utility] ## A more advanced timeout utility This implementation definitely works, but we can take it a couple steps further. An obvious improvement is the addition of a way to **clear a timeout**, which requires storing the ids of any active timeouts. This, along wi...
[A simple timeout promise > A more advanced timeout utility] ## A more advanced timeout utility This implementation definitely works, but we can take it a couple steps further. An obvious improvement is the addition of a way to **clear a timeout**, which requires storing the ids of any active timeouts. This, along wi...
code_snippets
c69ad801-7d4c-4c41-b85f-2f40ae67256b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/await-timeout.md
unknown
a3263d5d-cac8-4f66-a9d3-0f1a9829bae7
1
SemanticChunker@1.0.0
3d242d6fc42c57b3ea48190ca8fae6ef3b63173d0c98d4dcfa745af0d35cafd4
[A simple timeout promise] ## A simple timeout promise ```js const awaitTimeout = delay => new Promise(resolve => setTimeout(resolve, delay)); awaitTimeout(300).then(() => console.log('Hi')); // Logs 'Hi' after 300ms const f = async () => { await awaitTimeout(300); console.log('Hi'); // Logs 'Hi' after 300ms }; ...
unknown
unknown
[A simple timeout promise] ## A simple timeout promise ```js const awaitTimeout = delay => new Promise(resolve => setTimeout(resolve, delay)); awaitTimeout(300).then(() => console.log('Hi')); // Logs 'Hi' after 300ms const f = async () => { await awaitTimeout(300); console.log('Hi'); // Logs 'Hi' after 300ms }; ...
[A simple timeout promise] ## A simple timeout promise ```js const awaitTimeout = delay => new Promise(resolve => setTimeout(resolve, delay)); awaitTimeout(300).then(() => console.log('Hi')); // Logs 'Hi' after 300ms const f = async () => { await awaitTimeout(300); console.log('Hi'); // Logs 'Hi' after 300ms }; ...
code_snippets
d9e79055-a0bf-4113-9ad7-54d48bf14aa0
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/await-timeout.md
unknown
a3263d5d-cac8-4f66-a9d3-0f1a9829bae7
0
SemanticChunker@1.0.0
b9e015e47856ee3b25561be4eec023eb98b7778f755e014fc7336852af60d5d7
--- title: How can I add a timeout to a promise in JavaScript? shortTitle: Promise timeout language: javascript tags: [promises,timeout,class] cover: walking excerpt: Oftentimes you might need to add a timeout to a promise in JavaScript. Learn how to do this and more in this short guide. listed: true dateModified: 2024...
unknown
unknown
--- title: How can I add a timeout to a promise in JavaScript? shortTitle: Promise timeout language: javascript tags: [promises,timeout,class] cover: walking excerpt: Oftentimes you might need to add a timeout to a promise in JavaScript. Learn how to do this and more in this short guide. listed: true dateModified: 2024...
--- title: How can I add a timeout to a promise in JavaScript? shortTitle: Promise timeout language: javascript tags: [promises,timeout,class] cover: walking excerpt: Oftentimes you might need to add a timeout to a promise in JavaScript. Learn how to do this and more in this short guide. listed: true dateModified: 2024...
code_snippets
3b9c2127-7d96-454e-ad80-6ba2fd2a7547
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/byte-size.md
unknown
d2f6e736-972f-4c16-865e-b43826ec7813
0
SemanticChunker@1.0.0
70bf97e1dfc5f545f1a28006d41a379c531eb0a060774ff46eb7eaff594fbb84
--- title: Calculate the byte size of a JavaScript string shortTitle: Byte size of string language: javascript tags: [string] cover: mountain-lake-cottage-2 excerpt: Figure out the exact number of bytes in a JavaScript string, including Unicode characters. listed: true dateModified: 2024-03-09 --- Calculating the byte...
unknown
unknown
--- title: Calculate the byte size of a JavaScript string shortTitle: Byte size of string language: javascript tags: [string] cover: mountain-lake-cottage-2 excerpt: Figure out the exact number of bytes in a JavaScript string, including Unicode characters. listed: true dateModified: 2024-03-09 --- Calculating the byte...
--- title: Calculate the byte size of a JavaScript string shortTitle: Byte size of string language: javascript tags: [string] cover: mountain-lake-cottage-2 excerpt: Figure out the exact number of bytes in a JavaScript string, including Unicode characters. listed: true dateModified: 2024-03-09 --- Calculating the byte...
code_snippets
212f21c8-6ef9-47a2-8945-f06f2a31847d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/browser-os-detection.md
unknown
757be3ed-d12b-42c4-96aa-eb2c7e805479
2
SemanticChunker@1.0.0
27eda5beefd393c85d8ef78fc38a6e9a28078f486b9155fad7f39b81f4f25e1f
[`Navigator.platform` > `Navigator.userAgentData`] ## `Navigator.userAgentData` <baseline-support featureId="ua-client-hints"> </baseline-support> The consensus about the **bleeding edge solution** seems to revolve around `Navigator.userAgentData`, with some debate surrounding the need to use `NavigatorUAData.getHig...
unknown
unknown
[`Navigator.platform` > `Navigator.userAgentData`] ## `Navigator.userAgentData` <baseline-support featureId="ua-client-hints"> </baseline-support> The consensus about the **bleeding edge solution** seems to revolve around `Navigator.userAgentData`, with some debate surrounding the need to use `NavigatorUAData.getHig...
[`Navigator.platform` > `Navigator.userAgentData`] ## `Navigator.userAgentData` <baseline-support featureId="ua-client-hints"> </baseline-support> The consensus about the **bleeding edge solution** seems to revolve around `Navigator.userAgentData`, with some debate surrounding the need to use `NavigatorUAData.getHig...
code_snippets
24903ce9-5b07-4f26-974e-42fc8e5ad2d0
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/browser-os-detection.md
unknown
757be3ed-d12b-42c4-96aa-eb2c7e805479
0
SemanticChunker@1.0.0
aa28366be0b3361e73853fc3cc56cf5fa70dc9da38c4b84a53ef173ca4db3b24
--- title: Detect the user's OS in the browser with JavaScript shortTitle: Browser OS detection language: javascript tags: [browser] cover: dark-leaves-2 excerpt: Learn how to easily detect the user's operating system in the browser using JavaScript. listed: true dateModified: 2025-04-19 --- I was recently implementin...
unknown
unknown
--- title: Detect the user's OS in the browser with JavaScript shortTitle: Browser OS detection language: javascript tags: [browser] cover: dark-leaves-2 excerpt: Learn how to easily detect the user's operating system in the browser using JavaScript. listed: true dateModified: 2025-04-19 --- I was recently implementin...
--- title: Detect the user's OS in the browser with JavaScript shortTitle: Browser OS detection language: javascript tags: [browser] cover: dark-leaves-2 excerpt: Learn how to easily detect the user's operating system in the browser using JavaScript. listed: true dateModified: 2025-04-19 --- I was recently implementin...
code_snippets
34cd7c0e-ef83-4e6c-ac6f-26dd70b0ac62
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/browser-os-detection.md
unknown
757be3ed-d12b-42c4-96aa-eb2c7e805479
3
SemanticChunker@1.0.0
cf785ea27da67944bcc5415dbcf27909e79a82c7688597c9cca6373a1c6e2ea5
[`Navigator.platform` > `Navigator.userAgent`] ## `Navigator.userAgent` We've once more arrived at the trusty `Navigator.userAgent` property. We've previously seen how to use it to [detect device type](/js/s/detect-device-type). It's not as elegant, yet it works everywhere. ```js const isMac = /mac/i.test(navigator....
unknown
unknown
[`Navigator.platform` > `Navigator.userAgent`] ## `Navigator.userAgent` We've once more arrived at the trusty `Navigator.userAgent` property. We've previously seen how to use it to [detect device type](/js/s/detect-device-type). It's not as elegant, yet it works everywhere. ```js const isMac = /mac/i.test(navigator....
[`Navigator.platform` > `Navigator.userAgent`] ## `Navigator.userAgent` We've once more arrived at the trusty `Navigator.userAgent` property. We've previously seen how to use it to [detect device type](/js/s/detect-device-type). It's not as elegant, yet it works everywhere. ```js const isMac = /mac/i.test(navigator....
code_snippets
4769b87e-a07e-404e-8ede-723c7738bc78
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/browser-os-detection.md
unknown
757be3ed-d12b-42c4-96aa-eb2c7e805479
1
SemanticChunker@1.0.0
7ca075c9c62f1d7aae4ab24d25cfb1c070ed9e4582488003821e86129a4c5812
[`Navigator.platform`] ## `Navigator.platform` The most common answer online, and the one I was vaguely aware of, is based on the use of the `Navigator.platform` property. It's straightforward, too: ```js const isMac = navigator.platform.toLowerCase().includes('mac'); isMac; // true if the user is on a Mac, false o...
unknown
unknown
[`Navigator.platform`] ## `Navigator.platform` The most common answer online, and the one I was vaguely aware of, is based on the use of the `Navigator.platform` property. It's straightforward, too: ```js const isMac = navigator.platform.toLowerCase().includes('mac'); isMac; // true if the user is on a Mac, false o...
[`Navigator.platform`] ## `Navigator.platform` The most common answer online, and the one I was vaguely aware of, is based on the use of the `Navigator.platform` property. It's straightforward, too: ```js const isMac = navigator.platform.toLowerCase().includes('mac'); isMac; // true if the user is on a Mac, false o...
code_snippets
b7a307f0-539f-4d81-a6a2-93da5e4161db
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/browser-os-detection.md
unknown
757be3ed-d12b-42c4-96aa-eb2c7e805479
4
SemanticChunker@1.0.0
42098062e64b1022636435fa6863217c1838d60ef6f24f770dba67de50614f95
[`Navigator.platform` > Conclusion] ## Conclusion A simple task to detect the user's operating system in the browser can quickly spiral into a rabbit hole of figuring out what to use and how reliable it is. I guess the lesson here is that, even though JavaScript has come a very long way in recent years, we're still l...
unknown
unknown
[`Navigator.platform` > Conclusion] ## Conclusion A simple task to detect the user's operating system in the browser can quickly spiral into a rabbit hole of figuring out what to use and how reliable it is. I guess the lesson here is that, even though JavaScript has come a very long way in recent years, we're still l...
[`Navigator.platform` > Conclusion] ## Conclusion A simple task to detect the user's operating system in the browser can quickly spiral into a rabbit hole of figuring out what to use and how reliable it is. I guess the lesson here is that, even though JavaScript has come a very long way in recent years, we're still l...
code_snippets
e0cbc181-8090-4d69-8943-146ba12d22ea
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/bottom-visible.md
unknown
a0138fe2-aa46-43e2-9500-044bc2effb3c
0
SemanticChunker@1.0.0
70209cf358ea9988f53941e7ae181bc6c86eacadcc468f40b5225c065566f98b
--- title: Check if the bottom of the page is visible using JavaScript description: Check if bottom of page is visible language: javascript tags: [browser] cover: hiking-walking excerpt: If you've ever needed to check if the bottom of the page is visible, this article will help you do just that. listed: true dateModifi...
unknown
unknown
--- title: Check if the bottom of the page is visible using JavaScript description: Check if bottom of page is visible language: javascript tags: [browser] cover: hiking-walking excerpt: If you've ever needed to check if the bottom of the page is visible, this article will help you do just that. listed: true dateModifi...
--- title: Check if the bottom of the page is visible using JavaScript description: Check if bottom of page is visible language: javascript tags: [browser] cover: hiking-walking excerpt: If you've ever needed to check if the bottom of the page is visible, this article will help you do just that. listed: true dateModifi...
code_snippets
0d6a304d-baf4-48ed-8a34-aaa510f56e9e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/boolean-trap.md
unknown
0382aebb-7357-4d0e-b125-6af8bae02b7c
5
SemanticChunker@1.0.0
f0bc7e21e46ca8dd61e0937b1fcb15530ac915ff48571962e55d77143d537735
[Boolean trap - What's in a name? > Conclusion] ## Conclusion To summarize, boolean arguments in functions can be the source of a lot of wasted time and the cause for low code readability if used incorrectly. They're sometimes considered an anti-pattern as they increase cognitive load and reduce maintainability of sh...
unknown
unknown
[Boolean trap - What's in a name? > Conclusion] ## Conclusion To summarize, boolean arguments in functions can be the source of a lot of wasted time and the cause for low code readability if used incorrectly. They're sometimes considered an anti-pattern as they increase cognitive load and reduce maintainability of sh...
[Boolean trap - What's in a name? > Conclusion] ## Conclusion To summarize, boolean arguments in functions can be the source of a lot of wasted time and the cause for low code readability if used incorrectly. They're sometimes considered an anti-pattern as they increase cognitive load and reduce maintainability of sh...
code_snippets
6d9dbd31-151e-417e-84e1-238ac669961a
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/boolean-trap.md
unknown
0382aebb-7357-4d0e-b125-6af8bae02b7c
0
SemanticChunker@1.0.0
14bda71c36f414d142cd4ca4ec80ce300ea6b1ec54c23a5db93ef48163589264
--- title: Boolean traps and how to avoid them shortTitle: Boolean traps language: javascript tags: [function,type,boolean] cover: lighthouse excerpt: Boolean traps can cause readability and maintainability issues in your code. Learn what they are, how to spot and fix them in this article. listed: true dateModified: 20...
unknown
unknown
--- title: Boolean traps and how to avoid them shortTitle: Boolean traps language: javascript tags: [function,type,boolean] cover: lighthouse excerpt: Boolean traps can cause readability and maintainability issues in your code. Learn what they are, how to spot and fix them in this article. listed: true dateModified: 20...
--- title: Boolean traps and how to avoid them shortTitle: Boolean traps language: javascript tags: [function,type,boolean] cover: lighthouse excerpt: Boolean traps can cause readability and maintainability issues in your code. Learn what they are, how to spot and fix them in this article. listed: true dateModified: 20...
code_snippets
7f4872aa-e8d3-49ea-8d01-32abebe981db
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/boolean-trap.md
unknown
0382aebb-7357-4d0e-b125-6af8bae02b7c
3
SemanticChunker@1.0.0
2900f632ee90dc423a8ec0629f3c88c79644d3d0469acb16a35f0f71db960d16
[Boolean trap - What's in a name? > Not all booleans will trap you] ## Not all booleans will trap you As with most things, there is no universal best practice here. Even though I often find boolean arguments hard to read, I understand there are cases where you might want to use them. ```js // It should be obvious th...
unknown
unknown
[Boolean trap - What's in a name? > Not all booleans will trap you] ## Not all booleans will trap you As with most things, there is no universal best practice here. Even though I often find boolean arguments hard to read, I understand there are cases where you might want to use them. ```js // It should be obvious th...
[Boolean trap - What's in a name? > Not all booleans will trap you] ## Not all booleans will trap you As with most things, there is no universal best practice here. Even though I often find boolean arguments hard to read, I understand there are cases where you might want to use them. ```js // It should be obvious th...
code_snippets
cd7e0c4a-4b64-44b6-a698-bed92d13dc5c
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/boolean-trap.md
unknown
0382aebb-7357-4d0e-b125-6af8bae02b7c
2
SemanticChunker@1.0.0
ba8a1ca2f0c9b3b3e63f5028d166dd1a03397dcac0ebf83bb5deeb6ea95f026e
[Boolean trap - What's in a name? > Red flag or red herring?] ## Red flag or red herring? At this point, you might be asking yourself why this is actually bad. Reading through the documentation is expected. After all, that's what it's there for. Except this starts to become a waste of time on return visits. If you're...
unknown
unknown
[Boolean trap - What's in a name? > Red flag or red herring?] ## Red flag or red herring? At this point, you might be asking yourself why this is actually bad. Reading through the documentation is expected. After all, that's what it's there for. Except this starts to become a waste of time on return visits. If you're...
[Boolean trap - What's in a name? > Red flag or red herring?] ## Red flag or red herring? At this point, you might be asking yourself why this is actually bad. Reading through the documentation is expected. After all, that's what it's there for. Except this starts to become a waste of time on return visits. If you're...
code_snippets
f010d875-d097-4adf-bde7-00c89db813db
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/boolean-trap.md
unknown
0382aebb-7357-4d0e-b125-6af8bae02b7c
4
SemanticChunker@1.0.0
b0567e1ab17656d37fd197be8bc4e4e77ee1e5c6f71972f20e98f6b53d8171b2
[Boolean trap - What's in a name? > Mitigating the problem] ## Mitigating the problem We've already established what a boolean trap is and why it's bad. But how do we fix it? Even if we can spot the anti-pattern, it might be hard to change it before it affects a lot of code and developers. Some languages support name...
unknown
unknown
[Boolean trap - What's in a name? > Mitigating the problem] ## Mitigating the problem We've already established what a boolean trap is and why it's bad. But how do we fix it? Even if we can spot the anti-pattern, it might be hard to change it before it affects a lot of code and developers. Some languages support name...
[Boolean trap - What's in a name? > Mitigating the problem] ## Mitigating the problem We've already established what a boolean trap is and why it's bad. But how do we fix it? Even if we can spot the anti-pattern, it might be hard to change it before it affects a lot of code and developers. Some languages support name...
code_snippets
f99feb48-e6ca-4c77-b65b-5ad8ed21d8bc
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/boolean-trap.md
unknown
0382aebb-7357-4d0e-b125-6af8bae02b7c
1
SemanticChunker@1.0.0
34acbb5dbeaf2484e181a0f801239ed3e1ab088a4503e7f2c5e56e8aae26ac8e
[Boolean trap - What's in a name?] ## Boolean trap - What's in a name? While the name **Boolean trap** might be unfamiliar to some, I'm pretty certain the concept it represents isn't. The simplest form of a boolean trap is a function that takes a boolean argument. The **trap** in the name might throw you off if you ...
unknown
unknown
[Boolean trap - What's in a name?] ## Boolean trap - What's in a name? While the name **Boolean trap** might be unfamiliar to some, I'm pretty certain the concept it represents isn't. The simplest form of a boolean trap is a function that takes a boolean argument. The **trap** in the name might throw you off if you ...
[Boolean trap - What's in a name?] ## Boolean trap - What's in a name? While the name **Boolean trap** might be unfamiliar to some, I'm pretty certain the concept it represents isn't. The simplest form of a boolean trap is a function that takes a boolean argument. The **trap** in the name might throw you off if you ...
code_snippets
0ced38be-c51a-4d13-9c56-09b2e3d3ab41
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/brainfuck-interpreter-part-2.md
unknown
dda1ab2a-c742-4a3f-bfae-1d45f7c36c29
4
SemanticChunker@1.0.0
eeccd179fbfece8e365476886630b5261f9505795ae431fb0ad536aede6f5638
[The interpreter > Runner responsibilities] ``` As you can see, there's a lot going on here and we've yet to implement actual execution logic. We're relying on **Node.js streams** to make input and output configurable, allowing us to pass input as a string or make output print all out at once in debug mode. We're als...
unknown
unknown
[The interpreter > Runner responsibilities] ``` As you can see, there's a lot going on here and we've yet to implement actual execution logic. We're relying on **Node.js streams** to make input and output configurable, allowing us to pass input as a string or make output print all out at once in debug mode. We're als...
[The interpreter > Runner responsibilities] ``` As you can see, there's a lot going on here and we've yet to implement actual execution logic. We're relying on **Node.js streams** to make input and output configurable, allowing us to pass input as a string or make output print all out at once in debug mode. We're als...
code_snippets
18382210-0cc7-45d8-be53-0f9f3c12ca13
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/brainfuck-interpreter-part-2.md
unknown
dda1ab2a-c742-4a3f-bfae-1d45f7c36c29
9
SemanticChunker@1.0.0
ef20a4f66595dc57db2cbb6c07d7c55a6fe3e9be26c0ce1d2fddd7a5d6fade56
[Running the code > AST deserialization] ### AST deserialization Before we move forwards, I want to point out that we can write our AST to a file (e.g. via piping the output to a file), but we have no way of recreating it from that file yet. We'll add a `fromJSON` method to both the `AST` and `ASTNode` classes to tha...
unknown
unknown
[Running the code > AST deserialization] ### AST deserialization Before we move forwards, I want to point out that we can write our AST to a file (e.g. via piping the output to a file), but we have no way of recreating it from that file yet. We'll add a `fromJSON` method to both the `AST` and `ASTNode` classes to tha...
[Running the code > AST deserialization] ### AST deserialization Before we move forwards, I want to point out that we can write our AST to a file (e.g. via piping the output to a file), but we have no way of recreating it from that file yet. We'll add a `fromJSON` method to both the `AST` and `ASTNode` classes to tha...
code_snippets
33d33751-57f0-4bda-badd-bd637b605478
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/brainfuck-interpreter-part-2.md
unknown
dda1ab2a-c742-4a3f-bfae-1d45f7c36c29
7
SemanticChunker@1.0.0
c87de99b196073cea08fc3160264883f733243699424555ba952fb46f01d52d1
[Running the code > Running the nodes] ### Running the nodes The `ASTNode` class will now be given expected to have an `instruction` property, instead of its previous `execute()` method. We can simply update the `nodeTypes` definitions and the `constructor` to make this happen: ```js title="astNode.js" const nodeTyp...
unknown
unknown
[Running the code > Running the nodes] ### Running the nodes The `ASTNode` class will now be given expected to have an `instruction` property, instead of its previous `execute()` method. We can simply update the `nodeTypes` definitions and the `constructor` to make this happen: ```js title="astNode.js" const nodeTyp...
[Running the code > Running the nodes] ### Running the nodes The `ASTNode` class will now be given expected to have an `instruction` property, instead of its previous `execute()` method. We can simply update the `nodeTypes` definitions and the `constructor` to make this happen: ```js title="astNode.js" const nodeTyp...
code_snippets
6b573109-51ae-495b-b523-5dc02c0f115d
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/brainfuck-interpreter-part-2.md
unknown
dda1ab2a-c742-4a3f-bfae-1d45f7c36c29
5
SemanticChunker@1.0.0
1832f8aaf4d904d415d8fc5c1cc06f066e60d806afde41d0b1bfc63f41d8dc9f
[The interpreter > Running the code] ## Running the code In the previous iteration, we would run the code by calling `execute` on the `AST` object. We would then pass down the memory, input and output streams to the `ASTNode` objects, which would then call the appropriate methods on the `Memory` object. We won't dev...
unknown
unknown
[The interpreter > Running the code] ## Running the code In the previous iteration, we would run the code by calling `execute` on the `AST` object. We would then pass down the memory, input and output streams to the `ASTNode` objects, which would then call the appropriate methods on the `Memory` object. We won't dev...
[The interpreter > Running the code] ## Running the code In the previous iteration, we would run the code by calling `execute` on the `AST` object. We would then pass down the memory, input and output streams to the `ASTNode` objects, which would then call the appropriate methods on the `Memory` object. We won't dev...
code_snippets
6b9248c9-e965-4a2f-9207-ddc679c6f9ed
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/brainfuck-interpreter-part-2.md
unknown
dda1ab2a-c742-4a3f-bfae-1d45f7c36c29
2
SemanticChunker@1.0.0
9f0022318410aedb8ff88b76872ac517e4880da3d9c601291db4727d3885b99f
[The interpreter > Runner responsibilities] ### Runner responsibilities First and foremost, we need it to be able to **execute the program**, provided as an AST. Then, we want it to handle **input**, **output** and **memory management**. The input and output need to be **configurable**, so we can potentially supply a...
unknown
unknown
[The interpreter > Runner responsibilities] ### Runner responsibilities First and foremost, we need it to be able to **execute the program**, provided as an AST. Then, we want it to handle **input**, **output** and **memory management**. The input and output need to be **configurable**, so we can potentially supply a...
[The interpreter > Runner responsibilities] ### Runner responsibilities First and foremost, we need it to be able to **execute the program**, provided as an AST. Then, we want it to handle **input**, **output** and **memory management**. The input and output need to be **configurable**, so we can potentially supply a...
code_snippets
745c5219-d8b2-4e7d-bccd-e1e3291fa31e
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/brainfuck-interpreter-part-2.md
unknown
dda1ab2a-c742-4a3f-bfae-1d45f7c36c29
10
SemanticChunker@1.0.0
c0ff0587f9ed5789e99351fabd860bcef143bb5e49065cb6a205dbdd82ff8f9f
[Running the code > Executer] ### Executer The executer script is much more complex. We'll give it a few **flags** to allow it to configure the input, memory, debug mode and finally parse code, read from a file or accept an AST as input. ```js title="execute.js" #!/usr/bin/env node import { argv } from 'node:process...
unknown
unknown
[Running the code > Executer] ### Executer The executer script is much more complex. We'll give it a few **flags** to allow it to configure the input, memory, debug mode and finally parse code, read from a file or accept an AST as input. ```js title="execute.js" #!/usr/bin/env node import { argv } from 'node:process...
[Running the code > Executer] ### Executer The executer script is much more complex. We'll give it a few **flags** to allow it to configure the input, memory, debug mode and finally parse code, read from a file or accept an AST as input. ```js title="execute.js" #!/usr/bin/env node import { argv } from 'node:process...
code_snippets
88c6d7fc-8501-40a5-86bc-1c9489f3a3ba
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/brainfuck-interpreter-part-2.md
unknown
dda1ab2a-c742-4a3f-bfae-1d45f7c36c29
0
SemanticChunker@1.0.0
825c0d31acca99979a0af8fe29b6ecca5f18a73ff0c533807f0dcb336e4cad6b
--- title: Making a Brainfuck interpreter in JavaScript - Part 2 shortTitle: Brainfuck interpreter - Part 2 language: javascript tags: [algorithm] cover: mug-flower-book excerpt: Picking up where I left off last time, I'm wrapping up the Brainfuck interpreter, by making a simple VM for code execution and debugging. lis...
unknown
unknown
--- title: Making a Brainfuck interpreter in JavaScript - Part 2 shortTitle: Brainfuck interpreter - Part 2 language: javascript tags: [algorithm] cover: mug-flower-book excerpt: Picking up where I left off last time, I'm wrapping up the Brainfuck interpreter, by making a simple VM for code execution and debugging. lis...
--- title: Making a Brainfuck interpreter in JavaScript - Part 2 shortTitle: Brainfuck interpreter - Part 2 language: javascript tags: [algorithm] cover: mug-flower-book excerpt: Picking up where I left off last time, I'm wrapping up the Brainfuck interpreter, by making a simple VM for code execution and debugging. lis...
code_snippets
ab2504e3-030b-4ff1-9802-e71a29178d8b
unknown
file:///home/sanjeev/Downloads/depthapi/datasets/30-seconds-of-code/content/snippets/js/s/brainfuck-interpreter-part-2.md
unknown
dda1ab2a-c742-4a3f-bfae-1d45f7c36c29
1
SemanticChunker@1.0.0
0b344ebfc19f15ec5f5fadbd2d9a34c3e9d6ed45d95a65bf636d9739908ac2df
[The interpreter] ## The interpreter Previously, we explored how we can add an `execute` method to the `AST` and `ASTNode` classes to run the program. However, we may want far more flexibility in interpretation, especially if we were working with a more complex language with more instructions or more complex construc...
unknown
unknown
[The interpreter] ## The interpreter Previously, we explored how we can add an `execute` method to the `AST` and `ASTNode` classes to run the program. However, we may want far more flexibility in interpretation, especially if we were working with a more complex language with more instructions or more complex construc...
[The interpreter] ## The interpreter Previously, we explored how we can add an `execute` method to the `AST` and `ASTNode` classes to run the program. However, we may want far more flexibility in interpretation, especially if we were working with a more complex language with more instructions or more complex construc...
code_snippets