Rename articles prefixed with js-

This commit is contained in:
Angelos Chalaris
2023-05-18 23:29:52 +03:00
parent 2e31d65a39
commit 00f280bd16
63 changed files with 51 additions and 51 deletions

View File

@ -2,7 +2,7 @@ slug: js/array-initialization
name: JavaScript Array Initialization
featured: true
snippetIds:
- articles/s/js-array-initialization
- js/s/array-initialization
- js/s/initialize-array-with-values
- js/s/initialize-array-with-range
- js/s/initialize-array-with-range-right

View File

@ -2,15 +2,15 @@ slug: js/array-methods
name: JavaScript Array Methods
featured: true
snippetIds:
- articles/s/js-array-map-vs-foreach
- js/s/array-map-vs-foreach
- articles/s/4-javascript-array-methods
- js/s/array-comparison
- js/s/index-for-of-loop
- js/s/for-loop-early-break
- articles/s/js-array-initialization
- js/s/array-initialization
- articles/s/code-anatomy-chaining-reduce-for-loop
- js/s/async-array-loops
- articles/s/js-typecheck-array
- js/s/typecheck-array
splash: laptop-lamp.png
description: >-
JavaScript arrays offer a lot of data manipulation and transformation methods.

View File

@ -4,16 +4,16 @@ miniName: Data Structures
parent: js
featured: true
snippetIds:
- articles/s/js-native-data-structures
- articles/s/js-data-structures-queue
- articles/s/js-data-structures-stack
- articles/s/js-data-structures-linked-list
- articles/s/js-data-structures-doubly-linked-list
- articles/s/js-data-structures-graph
- articles/s/js-data-structures-tree
- articles/s/js-data-structures-binary-tree
- articles/s/js-data-structures-binary-search-tree
- articles/s/js-frequency-map-data-structure
- js/s/native-data-structures
- js/s/data-structures-queue
- js/s/data-structures-stack
- js/s/data-structures-linked-list
- js/s/data-structures-doubly-linked-list
- js/s/data-structures-graph
- js/s/data-structures-tree
- js/s/data-structures-binary-tree
- js/s/data-structures-binary-search-tree
- js/s/frequency-map-data-structure
- articles/s/big-o-cheatsheet
splash: purple-flower.png
description: >-

View File

@ -2,7 +2,7 @@ slug: js/dom-manipulation
name: JavaScript DOM Manipulation
featured: true
snippetIds:
- articles/s/js-create-html-elements
- js/s/create-html-elements
- js/s/create-element
- js/s/remove-element
- js/s/insert-after

View File

@ -13,7 +13,7 @@ snippetIds:
- js/s/element-is-visible-in-viewport
- articles/s/select-focused-dom-element
- js/s/get-elements-bigger-than-viewport
- articles/s/js-element-from-point
- js/s/element-from-point
- js/s/element-is-focused
- js/s/get-vertical-offset
- js/s/store-dom-items

View File

@ -10,7 +10,7 @@ snippetIds:
- js/s/undeclared-undefined-null
- js/s/variable-hoisting
- js/s/variable-scope
- articles/s/js-callbacks
- js/s/callbacks
- js/s/pass-by-reference-or-pass-by-value
- js/s/promises
- js/s/sync-async
@ -21,17 +21,17 @@ snippetIds:
- js/s/object-comparison
- js/s/array-comparison
- js/s/array-includes-value
- articles/s/js-array-map-vs-foreach
- js/s/array-map-vs-foreach
- js/s/event-bubbling-capturing-delegation
- js/s/value-not-equal-to-itself
- js/s/blank-value
- js/s/string-immutability
- articles/s/js-static-instance-methods
- js/s/static-instance-methods
- js/s/arrow-functions
- js/s/pure-functions
- js/s/recursion
- js/s/use-strict
- articles/s/js-async-defer
- js/s/async-defer
- js/s/closures
- js/s/iife
- js/s/event-loop-explained

View File

@ -4,13 +4,13 @@ featured: true
snippetIds:
- js/s/store-dom-items
- articles/s/passive-scroll-listener-performance
- articles/s/js-textcontent-or-innertext
- js/s/textcontent-or-innertext
- js/s/memoization
- articles/s/js-array-filtering-tips
- articles/s/js-fast-remove-array-element
- js/s/array-filtering-tips
- js/s/fast-remove-array-element
- articles/s/code-anatomy-optimizing-recursion
- js/s/switch-object
- articles/s/js-dynamic-properties-are-slow
- js/s/dynamic-properties-are-slow
- articles/s/big-o-cheatsheet
splash: do-more-computer.png
description: >-

View File

@ -2,15 +2,15 @@ slug: js/proxy
name: JavaScript Proxy
featured: true
snippetIds:
- articles/s/js-proxy-introduction
- articles/s/js-dynamic-getter-setter-proxy
- articles/s/js-immutable-object-proxy
- js/s/proxy-introduction
- js/s/dynamic-getter-setter-proxy
- js/s/immutable-object-proxy
- js/s/singleton-proxy
- articles/s/js-dynamic-getter-chain-proxy
- js/s/dynamic-getter-chain-proxy
- js/s/object-array-proxy
- articles/s/js-proxy-array-negative-index
- articles/s/js-cannot-extend-proxy-object
- articles/s/js-typecheck-proxy
- js/s/proxy-array-negative-index
- js/s/cannot-extend-proxy-object
- js/s/typecheck-proxy
splash: laptop-coffee.png
description: >-
The JavaScript Proxy object can be a very powerful tool to extend the

View File

@ -3,10 +3,10 @@ name: URLs in JavaScript
featured: true
snippetIds:
- js/s/modify-url-without-reload
- articles/s/js-construct-url
- articles/s/js-edit-url-params
- js/s/construct-url
- js/s/edit-url-params
- js/s/reload-page
- articles/s/js-window-location-cheatsheet
- js/s/window-location-cheatsheet
- js/s/current-url
- js/s/https-redirect
- js/s/get-url-parameters

View File

@ -27,27 +27,27 @@ Different data structures have different time complexities for the same operatio
| Data Structure | Access | Search | Insertion | Deletion |
| --- | --- | --- | --- | --- |
| [**Array**](/articles/s/js-native-data-structures) | Θ(1) | Θ(n) | Θ(n) | Θ(n) |
| [**Queue**](/articles/s/js-data-structures-queue) | Θ(n) | Θ(n) | Θ(1) | Θ(1) |
| [**Stack**](/articles/s/js-data-structures-stack) | Θ(n) | Θ(n) | Θ(1) | Θ(1) |
| [**Linked List**](/articles/s/js-data-structures-linked-list) | Θ(n) | Θ(n) | Θ(1) | Θ(1) |
| [**Doubly Linked List**](/articles/s/js-data-structures-doubly-linked-list) | Θ(n) | Θ(n) | Θ(1) | Θ(1) |
| [**Array**](/js/s/native-data-structures) | Θ(1) | Θ(n) | Θ(n) | Θ(n) |
| [**Queue**](/js/s/data-structures-queue) | Θ(n) | Θ(n) | Θ(1) | Θ(1) |
| [**Stack**](/js/s/data-structures-stack) | Θ(n) | Θ(n) | Θ(1) | Θ(1) |
| [**Linked List**](/js/s/data-structures-linked-list) | Θ(n) | Θ(n) | Θ(1) | Θ(1) |
| [**Doubly Linked List**](/js/s/data-structures-doubly-linked-list) | Θ(n) | Θ(n) | Θ(1) | Θ(1) |
| **Skip List** | Θ(log n) | Θ(log n) | Θ(log n) | Θ(log n) |
| **Hash Table** | N/A | Θ(1) | Θ(1) | Θ(1) |
| [**Binary Search Tree**](/articles/s/js-data-structures-binary-search-tree) | Θ(log n) | Θ(log n) | Θ(log n) | Θ(log n) |
| [**Binary Search Tree**](/js/s/data-structures-binary-search-tree) | Θ(log n) | Θ(log n) | Θ(log n) | Θ(log n) |
#### Worst time complexity
| Data Structure | Access | Search | Insertion | Deletion |
| --- | --- | --- | --- | --- |
| [**Array**](/articles/s/js-native-data-structures) | O(1) | O(n) | O(n) | O(n) |
| [**Queue**](/articles/s/js-data-structures-queue) | O(n) | O(n) | O(1) | O(1) |
| [**Stack**](/articles/s/js-data-structures-stack) | O(n) | O(n) | O(1) | O(1) |
| [**Linked List**](/articles/s/js-data-structures-linked-list) | O(n) | O(n) | O(1) | O(1) |
| [**Doubly Linked List**](/articles/s/js-data-structures-doubly-linked-list) | O(n) | O(n) | O(1) | O(1) |
| [**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(1) |
| [**Stack**](/js/s/data-structures-stack) | O(n) | O(n) | O(1) | O(1) |
| [**Linked List**](/js/s/data-structures-linked-list) | O(n) | O(n) | O(1) | O(1) |
| [**Doubly Linked List**](/js/s/data-structures-doubly-linked-list) | O(n) | O(n) | O(1) | O(1) |
| **Skip List** | O(n) | O(n) | O(n) | O(n) |
| **Hash Table** | N/A | O(n) | O(n) | O(n) |
| [**Binary Search Tree**](/articles/s/js-data-structures-binary-search-tree) | O(n) | O(n) | O(n) | O(n) |
| [**Binary Search Tree**](/js/s/data-structures-binary-search-tree) | O(n) | O(n) | O(n) | O(n) |
### Array sorting algorithms

View File

@ -10,7 +10,7 @@ excerpt: CORS (Cross-Origin Resource Sharing) trips up many developers, but it's
dateModified: 2023-05-07T05:00:00-04:00
---
When it comes to HTTP, an **origin** is defined by several different aspects of a URL. As mentioned in a [previous article](/articles/s/js-window-location-cheatsheet/), the origin is composed of the following:
When it comes to HTTP, an **origin** is defined by several different aspects of a URL. As mentioned in a [previous article](/js/s/window-location-cheatsheet/), the origin is composed of the following:
- The **protocol** (e.g. `http` or `https`)
- The **hostname** (e.g. `30secondsofcode.org`)

View File

@ -63,4 +63,4 @@ url.toString();
Admittedly, using the `URL` object can be a bit more verbose, but it's a worthwhile tradeoff. The code is much more readable and maintainable, and it's less prone to errors. Query parameters are now encoded properly, and delimiters are added automatically.
While query parameters are the most common issue when dealing with URLs, the `URL` object can be useful in many other situations. For example, you can change the protocol, hostname, port, path, hash, etc. of a URL, or even parse an existing URL into its components. If you're interested, you should check out previous articles about how you can [edit URL parameters](/articles/s/js-edit-url-params) and the [`window.location` cheat sheet](/articles/s/js-window-location-cheatsheet).
While query parameters are the most common issue when dealing with URLs, the `URL` object can be useful in many other situations. For example, you can change the protocol, hostname, port, path, hash, etc. of a URL, or even parse an existing URL into its components. If you're interested, you should check out previous articles about how you can [edit URL parameters](/js/s/edit-url-params) and the [`window.location` cheat sheet](/js/s/window-location-cheatsheet).

View File

@ -12,7 +12,7 @@ dateModified: 2023-05-28T05:00:00-04:00
The dawn of ES6 brought about jQuery's fall from grace, as a lot of the conveniences it afforded developers were now available in the language itself. However, jQuery's API design was convenient in many ways that native JavaScript often isn't. One of the most practical things jQuery offered was its ability to chain methods together, minimizing duplication and making code more readable.
Looking at the use case at hand, I thought that I could stitch together a general-purpose solution using JavaScript's `Proxy` object. In fact, I think that the concept of dynamic getters and setters that I described in [my previous post](/articles/s/js-dynamic-getter-setter-proxy) is a great place to start.
Looking at the use case at hand, I thought that I could stitch together a general-purpose solution using JavaScript's `Proxy` object. In fact, I think that the concept of dynamic getters and setters that I described in [my previous post](/js/s/dynamic-getter-setter-proxy) is a great place to start.
To recap, intercepting the behavior of the `get` and `set` traps of a `Proxy` object allows us to create dynamic accessors for objects. This is particularly useful when the shape of the data is not known in advance, or when the value of a property needs to be manipulated before it is returned.

View File

@ -54,7 +54,7 @@ for (let item of myList) {
}
```
In the above example, we implement a [`LinkedList` data structure](/articles/s/js-data-structures-linked-list), that internally uses a `data` array. Each item in it has a `value` and some implementation-specific properties used to determine its position in the sequence. Objects constructed from this class are not iterable by default. To define an iterator we use `Symbol.iterator` and set it up so that the returned sequence is in order based on the internal implementation of the class, while the returned items only return their `value`.
In the above example, we implement a [`LinkedList` data structure](/js/s/data-structures-linked-list), that internally uses a `data` array. Each item in it has a `value` and some implementation-specific properties used to determine its position in the sequence. Objects constructed from this class are not iterable by default. To define an iterator we use `Symbol.iterator` and set it up so that the returned sequence is in order based on the internal implementation of the class, while the returned items only return their `value`.
On a related note, iterators are just functions, meaning they can be called like any other function (e.g. to delegate the iteration to an existing iterator), while also not being restricted to the `Symbol.iterator` name. This allows us to define multiple iterators for the same object. Here's an example of these concepts at play:

View File

@ -40,5 +40,5 @@ Most of the time, `Array.prototype.filter()` is the best option for removing ele
### Alternative options
The previous two options should cover the vast majority of use cases. Yet, there are some other options available for removing elements from an array, which might be preferable in certain cases. For example, if you like the interface of `Array.prototype.splice()` but need immutability, the [shank snippet](/js/s/shank) might be the solution for you. Similarly, when working with large unsorted arrays, there's a [fast removal trick](/articles/s/js-fast-remove-array-element) that might be of interest to you.
The previous two options should cover the vast majority of use cases. Yet, there are some other options available for removing elements from an array, which might be preferable in certain cases. For example, if you like the interface of `Array.prototype.splice()` but need immutability, the [shank snippet](/js/s/shank) might be the solution for you. Similarly, when working with large unsorted arrays, there's a [fast removal trick](/js/s/fast-remove-array-element) that might be of interest to you.