12 |
13 |
14 |
15 | Anyone can forget how to
16 | [make character classes](https://www.javascriptcheatsheet.org/cheatsheet/regular-expressions#making-your-own-character-classes)
17 | for a regex, [slice a list](https://www.javascriptcheatsheet.org/cheatsheet/array-methods#array-slice) or do a [for loop](https://www.javascriptcheatsheet.org/cheatsheet/control-flow#for-loop). This javascript cheatsheet tries to provide basic reference for beginner and advanced developers, lower the entry barrier for newcomers and help veterans refresh the old tricks.
18 |
19 | ## Contributors
20 |
21 |
22 |
23 |
24 |
25 | Made with [contrib.rocks](https://contrib.rocks).
26 |
27 |
--------------------------------------------------------------------------------
/contributors/contributors.json:
--------------------------------------------------------------------------------
1 | [
2 | "wilfredinni",
3 | "Harish-clb",
4 | "hcz1",
5 | "Kishore007raj",
6 | "CodeWithBishal",
7 | "chrishenderson07",
8 | "gritgary101",
9 | "KamleshPandey98",
10 | "engtuncay"
11 | ]
--------------------------------------------------------------------------------
/contributors/contributors.ts:
--------------------------------------------------------------------------------
1 | import contributorNames from './contributors.json'
2 |
3 | export interface Contributor {
4 | name: string
5 | avatar: string
6 | repository: string
7 | }
8 |
9 | const contributorsAvatars: Record = {}
10 |
11 | const getAvatarUrl = (name: string) =>
12 | import.meta.hot
13 | ? `https://github.com/${name}.png`
14 | : `/user-avatars/${name}.png`
15 |
16 | export const contributors = (contributorNames as string[]).reduce(
17 | (acc, name) => {
18 | contributorsAvatars[name] = getAvatarUrl(name)
19 | acc.push({
20 | name,
21 | avatar: contributorsAvatars[name],
22 | repository: `https://github.com/${name}`,
23 | })
24 | return acc
25 | },
26 | [] as Contributor[]
27 | )
28 |
--------------------------------------------------------------------------------
/docs/cheatsheet/arrays.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Javascript Arrays - Javascript Cheatsheet
3 | description: An array in JavaScript is a high-level, list-like object that is used to store multiple values in a single variable.
4 | ---
5 |
6 |
7 | Javascript Arrays
8 |
9 |
10 |
11 |
12 | From the MDN Web Docs
13 |
14 |
15 | The Array object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name, and has members for performing common array operations.
16 |
17 |
18 |
19 | An array in JavaScript is a high-level, list-like object that is used to store multiple values in a single variable. Each value (also called an element) in an array has a numeric position, known as its index, and it can contain data of any type—numbers, strings, booleans, functions, objects, and even other arrays:
20 |
21 | ```javascript
22 | let fruits = ['apple', 'banana', 'cherry'];
23 | ```
24 |
25 | ## Array Declaration
26 |
27 | In JavaScript, an array can be declared in several ways:
28 |
29 | 1. **Array literal**: This is the most common way to create an array. It uses square brackets `[]` and the elements are comma-separated.
30 |
31 | ```javascript
32 | let fruits = ['apple', 'banana', 'cherry'];
33 | ```
34 |
35 | 2. **Array constructor**: This uses the `new` keyword along with the `Array` constructor. It's less common and more verbose.
36 |
37 | ```javascript
38 | let fruits = new Array('apple', 'banana', 'cherry');
39 | ```
40 |
41 | 3. **Array.of() method**: This creates a new Array instance from a variable number of arguments.
42 |
43 | ```javascript
44 | let fruits = Array.of('apple', 'banana', 'cherry');
45 | ```
46 |
47 | 4. **Array.from() method**: This creates a new Array instance from an array-like or iterable object.
48 |
49 | ```javascript
50 | let fruits = Array.from(['apple', 'banana', 'cherry']);
51 | ```
52 |
53 | In all these examples, `fruits` is an array that contains three strings. The strings are the elements of the array.
54 |
55 | ## Array Indexes
56 |
57 | In JavaScript, each item in an array is assigned a numeric position, known as its index. Array indices start at 0 and increment by 1 for each subsequent element.
58 |
59 | ```javascript
60 | let fruits = ['apple', 'banana', 'cherry'];
61 |
62 | console.log(fruits[0]); // logs 'apple'
63 | console.log(fruits[1]); // logs 'banana'
64 | console.log(fruits[2]); // logs 'cherry'
65 | ```
66 |
67 | Here, 'apple' is at index 0, 'banana' is at index 1, and 'cherry' is at index 2 in the `fruits` array.
68 |
69 | You can use the index to access or modify the elements of the array:
70 |
71 | ```javascript
72 | fruits[1] = 'blueberry'; // changes 'banana' to 'blueberry'
73 | console.log(fruits[1]); // logs 'blueberry'
74 | ```
75 |
76 | In this case, `fruits[1] = 'blueberry'` changes the second element of the array to 'blueberry'.
77 |
78 | ## Array Length
79 |
80 | The `length` property of an array in JavaScript returns the number of elements in the array. It's not a method, so you don't call it with parentheses.
81 |
82 | ```javascript
83 | let fruits = ['apple', 'banana', 'cherry'];
84 | console.log(fruits.length); // logs 3
85 | ```
86 |
87 | `fruits.length` is 3 because there are three elements in the `fruits` array.
88 |
89 | You can also use the `length` property to change the number of elements in an array:
90 |
91 | ```javascript
92 | fruits.length = 2;
93 | console.log(fruits); // logs ['apple', 'banana']
94 | ```
95 |
96 | Setting `fruits.length = 2` removes the last element from the array, so the array now only contains 'apple' and 'banana'.
97 |
98 | ## Array destructuring
99 |
100 | Array destructuring in JavaScript is a syntax that allows you to unpack values from arrays, or properties from objects, into distinct variables.
101 |
102 | ```javascript
103 | let fruits = ['apple', 'banana', 'cherry'];
104 |
105 | let [fruit1, fruit2, fruit3] = fruits;
106 |
107 | console.log(fruit1); // logs 'apple'
108 | console.log(fruit2); // logs 'banana'
109 | console.log(fruit3); // logs 'cherry'
110 | ```
111 |
112 | In this example, the array `fruits` is destructured into three new variables `fruit1`, `fruit2`, and `fruit3`. The first element of the array is assigned to `fruit1`, the second element to `fruit2`, and the third element to `fruit3`.
113 |
114 | You can also skip over elements that you don't need:
115 |
116 | ```javascript
117 | let [fruit1, , fruit3] = fruits;
118 |
119 | console.log(fruit1); // logs 'apple'
120 | console.log(fruit3); // logs 'cherry'
121 | ```
122 |
123 | The second element of the array is skipped and not assigned to any variable.
124 |
125 | ## The Spread Operator
126 |
127 | The `...` notation in JavaScript is known as the spread operator. It allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected.
128 |
129 | Here's an example of how to create a new array using the spread operator:
130 |
131 | ```javascript
132 | let fruits = ['apple', 'banana', 'cherry'];
133 | let moreFruits = [...fruits, 'date', 'elderberry'];
134 |
135 | console.log(moreFruits); // logs ['apple', 'banana', 'cherry', 'date', 'elderberry']
136 | ```
137 |
138 | Here, `...fruits` expands the elements of the `fruits` array into individual elements. The `moreFruits` array is a new array that contains all the elements of the `fruits` array, followed by 'date' and 'elderberry'.
139 |
140 | You can also use the spread operator to combine two arrays:
141 |
142 | ```javascript
143 | let fruits1 = ['apple', 'banana'];
144 | let fruits2 = ['cherry', 'date'];
145 | let allFruits = [...fruits1, ...fruits2];
146 |
147 | console.log(allFruits); // logs ['apple', 'banana', 'cherry', 'date']
148 | ```
149 |
150 | `...fruits1` and `...fruits2` expand the elements of the `fruits1` and `fruits2` arrays into individual elements. The `allFruits` array is a new array that contains all the elements of the `fruits1` and `fruits2` arrays.
--------------------------------------------------------------------------------
/docs/cheatsheet/error-handling.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Javascript Error Handling - Javascript Cheatsheet
3 | description: Error handling in programming is the process of responding to and managing errors that occur during the execution of a program.
4 | ---
5 |
6 |
7 | Javascript Error Handling
8 |
9 |
10 | Error handling in programming is the process of responding to and managing errors that occur during the execution of a program.
11 |
12 |
13 |
14 | Why is Error Handling Important?
15 |
16 |
17 | Error handling is important because it helps to ensure that your program can continue to function (or fail gracefully) even when unexpected conditions occur.
18 |
19 |
20 |
21 | Errors can occur for a variety of reasons, such as user input that the program doesn't know how to handle, system resources being unavailable, or unexpected conditions in the program's logic.
22 |
23 |
24 | ## Try...Catch Statements
25 |
26 | Error handling is typically done using `try...catch` statements:
27 |
28 | ```javascript
29 | try {
30 | // Code that may throw an error
31 | } catch (error) {
32 | // Code to handle the error
33 | }
34 | ```
35 |
36 | In the `try` block, you write the code that may throw an error. In the `catch` block, you write the code to handle the error. The error object that is passed to the `catch` block contains information about the error, such as its name and message.
37 |
38 | ```javascript
39 | try {
40 | let x = y; // y is not defined, so an error is thrown
41 | } catch (error) {
42 | console.log(error.message); // Outputs: "y is not defined"
43 | }
44 | ```
45 |
46 | **y** is not defined, so when we try to assign its value to **x**, an error is thrown. The catch block catches this error and logs its message to the console.
47 |
48 | ## Finally Block
49 |
50 | There's also a `finally` block that can be added after `catch`, which will be executed regardless of whether an error was thrown or caught:
51 |
52 | ```javascript
53 | try {
54 | // Code that may throw an error
55 | } catch (error) {
56 | // Code to handle the error
57 | } finally {
58 | // Code to be executed regardless of an error
59 | }
60 | ```
61 |
62 | ## Throwing Errors
63 |
64 | Throwing errors in programming is a way to handle unexpected or exceptional conditions. It allows a function to indicate that it is unable to proceed with its normal execution, and gives control back to the part of the program that called the function.
65 |
66 | In many programming languages, you can "throw" an error (or "raise" an exception) with a `throw` statement.
67 |
68 | ```javascript
69 | function divide(a, b) {
70 | if (b === 0) {
71 | throw new Error("Division by zero is not allowed");
72 | }
73 | return a / b;
74 | }
75 | ```
76 |
77 | If the function `divide` is called with the second argument as `0`, it will throw an error. The calling code can then "catch" this error and handle it appropriately.
78 |
79 | ## Custom Error Types
80 |
81 | Creating custom error types can be useful when you want to throw and catch errors that represent specific conditions in your program. This allows you to handle different types of errors in different ways.
82 |
83 | Here's an example of how you can define and use a custom error type:
84 |
85 | ```javascript
86 | class DivisionByZeroError extends Error {
87 | constructor() {
88 | super("Division by zero is not allowed");
89 | this.name = "DivisionByZeroError";
90 | }
91 | }
92 |
93 | function divide(a, b) {
94 | if (b === 0) {
95 | throw new DivisionByZeroError();
96 | }
97 | return a / b;
98 | }
99 |
100 | try {
101 | console.log(divide(1, 0));
102 | } catch (error) {
103 | if (error instanceof DivisionByZeroError) {
104 | console.log(error.message);
105 | } else {
106 | throw error;
107 | }
108 | }
109 | ```
110 |
111 | `DivisionByZeroError` is a custom error type that extends the built-in `Error` type. When `divide` is called with `0` as the second argument, it throws a `DivisionByZeroError`. The `try`/`catch` block then catches this error and handles it by logging the error message to the console.
112 |
113 | ## Error Propagation
114 |
115 | Error propagation refers to the process by which errors (or exceptions) are passed up the call stack from where they were thrown until they are caught by an appropriate error handler.
116 |
117 | In many programming languages, when an error is thrown and not immediately caught within the same function or method, it propagates up to the calling function. This continues until the error is either caught and handled, or it reaches the top level of the call stack, at which point the program typically crashes with an unhandled exception error.
118 |
119 | Here's an example in JavaScript:
120 |
121 | ```javascript
122 | function function1() {
123 | function2();
124 | }
125 |
126 | function function2() {
127 | throw new Error("An error occurred");
128 | }
129 |
130 | try {
131 | function1();
132 | } catch (error) {
133 | console.log("Caught an error: " + error.message);
134 | }
135 | ```
136 |
137 | `function2` throws an error. Since it's not caught within `function2`, it propagates up to `function1`. Again, it's not caught there, so it propagates up to the top level, where it is finally caught in the `try`/`catch` block.
138 |
139 | ## Asynchronous Error Handling
140 |
141 | Asynchronous error handling is a bit different from synchronous error handling. In asynchronous programming, because the operations are not blocking, errors can't be caught with a simple `try`/`catch` block.
142 |
143 | There are a few ways to handle errors in asynchronous code:
144 |
145 | 1. **Callbacks**: The most traditional way is to use a callback function that takes an error as its first argument.
146 |
147 | ```javascript
148 | fs.readFile('nonexistent-file.txt', function(err, data) {
149 | if (err) {
150 | console.error('There was an error reading the file!', err);
151 | return;
152 | }
153 | // Otherwise handle the data
154 | });
155 | ```
156 |
157 | 2. **Promises**: Promises have `.catch` method to handle any errors that might have occurred in the promise chain.
158 |
159 | ```javascript
160 | doSomething()
161 | .then(result => doSomethingElse(result))
162 | .then(newResult => doAnotherThing(newResult))
163 | .catch(error => console.error(error));
164 | ```
165 |
166 | 3. **Async/Await**: With async/await, you can use a `try`/`catch` block to handle errors, which can make your asynchronous code look and behave a little more like synchronous code.
167 |
168 | ```javascript
169 | async function doSomethingAsync() {
170 | try {
171 | const result = await doSomething();
172 | const newResult = await doSomethingElse(result);
173 | await doAnotherThing(newResult);
174 | } catch (error) {
175 | console.error(error);
176 | }
177 | }
178 | ```
179 |
180 | In all these cases, the key is to make sure that any function that might throw an error is properly handled to prevent the error from propagating up and crashing your program.
181 |
--------------------------------------------------------------------------------
/docs/cheatsheet/manipulating-strings.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Javascript String Manipulation - Javascript Cheatsheet
3 | description: String manipulation refers to the process of changing, parsing, slicing, or analyzing strings in various ways.
4 | ---
5 |
6 |
7 | Javascript String Manipulation
8 |
9 |
10 |
11 |
12 | Manipulating Strings
13 |
14 |
15 | String manipulation refers to the process of changing, parsing, slicing, or analyzing strings in various ways.
16 |
17 |
18 |
19 | ## Concat
20 |
21 | The `concat` method is used to join two or more strings together. This method does not change the existing strings, but returns a new string containing the text of the joined strings.
22 |
23 | ```javascript
24 | let str1 = "Hello, ";
25 | let str2 = "World!";
26 | let result = str1.concat(str2);
27 |
28 | console.log(result); // Outputs: "Hello, World!"
29 | ```
30 |
31 | `str1` and `str2` are two strings. The `concat` method is called on `str1` with `str2` as the argument, resulting in a new string that is the concatenation of `str1` and `str2`. The new string is stored in the `result` variable.
32 |
33 | ## CharAt
34 |
35 | `charAt` method is used to get the character at a specific index in a string. The index of the first character is 0, the second character is 1, and so on.
36 |
37 | ```javascript
38 | let str = "Hello, World!";
39 | let char = str.charAt(7);
40 |
41 | console.log(char); // Outputs: "W"
42 | ```
43 |
44 | Here, `str` is a string. The `charAt` method is called on `str` with 7 as the argument, which corresponds to the 8th character in the string (since the index is 0-based). The character at this index is "W", so "W" is stored in the `char` variable and then logged to the console.
45 |
46 | ## Includes
47 |
48 | The `includes` method is used to determine whether one string can be found within another string, returning true or false as appropriate. It performs a case-sensitive search.
49 |
50 | ```javascript
51 | let str = "Hello, World!";
52 | let result = str.includes("World");
53 |
54 | console.log(result); // Outputs: true
55 | ```
56 |
57 | `str` is a string. The `includes` method is called on `str` with "World" as the argument. Since "World" is a substring of `str`, the `includes` method returns true, which is stored in the `result` variable and then logged to the console.
58 |
59 | ## IndexOf
60 |
61 | `indexOf` method is used to determine the first occurrence of a specified value in a string. It returns the index of the value if found, or -1 if the value is not found. The search is case-sensitive.
62 |
63 | ```javascript
64 | let str = "Hello, World!";
65 | let index = str.indexOf("World");
66 |
67 | console.log(index); // Outputs: 7
68 | ```
69 |
70 | `str` is a string. The `indexOf` method is called on `str` with "World" as the argument. Since "World" is a substring of `str` and starts at index 7, the `indexOf` method returns 7, which is stored in the `index` variable and then logged to the console.
71 |
72 | ## Slice
73 |
74 | The `slice` method is used to extract a section of a string and returns it as a new string, without modifying the original string. The method takes two parameters: the start index (inclusive), and the end index (exclusive).
75 |
76 | ```javascript
77 | let str = "Hello, World!";
78 | let slicedStr = str.slice(7, 12);
79 |
80 | console.log(slicedStr); // Outputs: "World"
81 | ```
82 |
83 | Here, `str` is a string. The `slice` method is called on `str` with 7 as the start index and 12 as the end index. This extracts the substring starting from the 8th character up to (but not including) the 13th character. The resulting substring "World" is stored in the `slicedStr` variable and then logged to the console.
84 |
85 | ## Split
86 |
87 | The `split` method is used to divide a string into an array of substrings. It takes a separator as an argument, which specifies the character(s) to use for separating the string. If the separator is not provided, the entire string will be returned as a single element in an array.
88 |
89 | ```javascript
90 | let str = "Hello, World!";
91 | let array = str.split(", ");
92 |
93 | console.log(array); // Outputs: ["Hello", "World!"]
94 | ```
95 |
96 | `str` is a string. The `split` method is called on `str` with ", " as the separator. This divides the string into two substrings "Hello" and "World!", which are returned as elements in an array. The array is stored in the `array` variable and then logged to the console.
97 |
98 | ## Replace
99 |
100 | The `replace` method is used to replace a specified value with another value in a string. It returns a new string with some or all matches of a pattern replaced by a replacement. The original string is not modified.
101 |
102 | ```javascript
103 | let str = "Hello, World!";
104 | let newStr = str.replace("World", "Universe");
105 |
106 | console.log(newStr); // Outputs: "Hello, Universe!"
107 | ```
108 |
109 | `str` is a string. The `replace` method is called on `str` with "World" as the pattern to be replaced and "Universe" as the replacement. This results in a new string "Hello, Universe!", which is stored in the `newStr` variable and then logged to the console.
110 |
111 | ## ToLowerCase
112 |
113 | The `toLowerCase` method is used to convert a string to lowercase letters. This method does not change the original string, but returns a new string where all the uppercase characters are converted to lowercase.
114 |
115 | ```javascript
116 | let str = "Hello, World!";
117 | let lowerCaseStr = str.toLowerCase();
118 |
119 | console.log(lowerCaseStr); // Outputs: "hello, world!"
120 | ```
121 |
122 | `str` is a string. The `toLowerCase` method is called on `str`, resulting in a new string where all the uppercase characters are converted to lowercase. The new string is stored in the `lowerCaseStr` variable and then logged to the console.
123 |
124 | ## ToUpperCase
125 |
126 | The `toUpperCase` method is used to convert a string to uppercase letters. This method does not change the original string, but returns a new string where all the lowercase characters are converted to uppercase.
127 |
128 | Here's an example of how to use the `toUpperCase` method:
129 |
130 | ```javascript
131 | let str = "Hello, World!";
132 | let upperCaseStr = str.toUpperCase();
133 |
134 | console.log(upperCaseStr); // Outputs: "HELLO, WORLD!"
135 | ```
136 |
137 | `str` is a string. The `toUpperCase` method is called on `str`, resulting in a new string where all the lowercase characters are converted to uppercase. The new string is stored in the `upperCaseStr` variable and then logged to the console.
138 |
139 | ## Trim
140 |
141 | The `trim` method is used to remove whitespace from both ends of a string. This method does not change the original string, but returns a new string with the whitespace removed.
142 |
143 | ```javascript
144 | let str = " Hello, World! ";
145 | let trimmedStr = str.trim();
146 |
147 | console.log(trimmedStr); // Outputs: "Hello, World!"
148 | ```
149 |
150 | `str` is a string with leading and trailing whitespace. The `trim` method is called on `str`, resulting in a new string where the whitespace at both ends is removed. The new string is stored in the `trimmedStr` variable and then logged to the console.
151 |
152 | ## TrimLeft and TrimRight
153 |
154 | `trimLeft` and `trimRight` methods are used to remove whitespace from the beginning and end of a string respectively. These methods do not change the original string, but return a new string with the whitespace removed.
155 |
156 | ```javascript
157 | let str = " Hello, World! ";
158 | let trimmedLeftStr = str.trimLeft();
159 | let trimmedRightStr = str.trimRight();
160 |
161 | console.log(trimmedLeftStr); // Outputs: "Hello, World! "
162 | console.log(trimmedRightStr); // Outputs: " Hello, World!"
163 | ```
164 |
165 | In this example, `str` is a string with leading and trailing whitespace. The `trimLeft` method is called on `str`, resulting in a new string where the whitespace at the beginning is removed. Similarly, the `trimRight` method is called on `str`, resulting in a new string where the whitespace at the end is removed. The new strings are stored in the `trimmedLeftStr` and `trimmedRightStr` variables and then logged to the console.
166 |
--------------------------------------------------------------------------------
/docs/cheatsheet/map.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Javascript Map Object - Javascript Cheatsheet
3 | description: A Map is a built in object that holds key-value pairs. It can hold a key of any data type unlike in plain objects. It maintains the insertion order and provides helpers to manage key-value pairs.
4 | ---
5 |
6 |
7 | Javascript Map Object
8 |
9 |
10 |
11 |
12 | Javascript Map Object
13 |
14 |
15 | A Map is a built in object that holds key-value pairs. It can hold a key of any data type unlike in plain objects. It maintains the insertion order and provides helpers to manage key-value pairs.
16 |
17 |
18 |
19 | ## Creating a Map
20 |
21 | Creates an empty `Map` instance.
22 |
23 | ```javascript
24 | const map = new Map()
25 | ```
26 |
27 | ## Initializing a Map
28 |
29 | You can initialize a Map with an array of key-value pairs.
30 |
31 | ```javascript
32 | const map = new Map([
33 | ['id', 1], // key: 'id', value: 1
34 | ['name', 'Alice'], // key: 'name', value: 'Alice'
35 | ])
36 | ```
37 |
38 | ## Map Size
39 |
40 | `size` property returns the number of key-value pairs in a map.
41 | It returns a number.
42 |
43 | ```javascript
44 | map.size // 2
45 | ```
46 |
47 | ## Map Set
48 |
49 | The `set(key, value)` method adds a key-value pair.
50 | If a key exists already, the value will be updated.
51 | `set()` affects the size of a map.
52 |
53 | ```javascript
54 | map.set('age', 50) // sets new key 'age' with value 50
55 | map.set(2, 200) // sets new key 2 with value 200
56 | map.set('id', 2) // id key already exists, so value of id will be updated to 2
57 |
58 | // Check size
59 | map.size // 4
60 | ```
61 |
62 | You can also chain `set` like `map.set(key, value).set(key, value)`
63 |
64 | ## Map Get
65 |
66 | The `get(key)` retrieves the value of the specified key.
67 | If a key exists, its value will be returned otherwise undefined.
68 |
69 | ```javascript
70 | map.get('age') // 50
71 | map.get('none') // undefined as key 'none' do not exist
72 | ```
73 |
74 | ## Map Has
75 |
76 | The `has(key)` returns a boolean by checking the key existence.
77 |
78 | ```javascript
79 | map.has('id') // true
80 | map.has('none') // false
81 | ```
82 |
83 | ## Map Delete
84 |
85 | The `delete(key)` method removes the key-value pair with the specified key.
86 | It returns true if the key exists, otherwise false.
87 | `delete()` affects the size of a map.
88 |
89 | ```javascript
90 | map.delete('age') // true as key 'age' exists
91 | map.delete('none') // false as key 'none' do not exist
92 |
93 | // Check size
94 | map.size // 3
95 | ```
96 |
97 | ## Map Clear
98 |
99 | The `clear` method removes all key-value pairs from the map.
100 | `clear` affects the size of a map.
101 |
102 | ```javascript
103 | map.clear()
104 |
105 | // Check size
106 | map.size // 0
107 | ```
108 |
109 | ## Iterate Map using for ... of
110 |
111 | You can directly iterate using `for ... of` over each key-value pair.
112 |
113 | ```javascript
114 | const map = new Map()
115 | map.set('name', 'Bob').set('age', 20)
116 | for (const [key, value] of map) {
117 | console.log(`${key}: ${value}`)
118 | }
119 |
120 | // name: Bob
121 | // age: 20
122 | ```
123 |
124 | ## Iterate Map using keys()
125 |
126 | You can iterate over the map keys using `keys()` method as in the order it was inserted.
127 |
128 | ```javascript
129 | const map = new Map()
130 | map.set('name', 'Bob').set('age', 20)
131 | for (const key of map.keys()) {
132 | console.log(`${key}`)
133 | }
134 |
135 | // name
136 | // age
137 | ```
138 |
139 | ## Iterate Map using values()
140 |
141 | You can iterate over the map values using `values()` method as in the order it was inserted.
142 |
143 | ```javascript
144 | const map = new Map()
145 | map.set('name', 'Bob').set('age', 20)
146 | for (const value of map.values()) {
147 | console.log(`${value}`)
148 | }
149 |
150 | // Bob
151 | // 20
152 | ```
153 |
154 | ## Iterate Map using entries()
155 |
156 | You can iterate over the map's key-value pair using `entries()` method as in the order it was inserted.
157 |
158 | ```javascript
159 | const map = new Map()
160 | map.set('name', 'Bob').set('age', 20)
161 | for (let [key, value] of map.entries()) {
162 | console.log(`${key}: ${value}`)
163 | }
164 |
165 | // name: Bob
166 | // age: 20
167 | ```
168 |
--------------------------------------------------------------------------------
/docs/cheatsheet/objects.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Javascript Objects - Javascript Cheatsheet
3 | description: JavaScript objects are containers for named values, called properties and methods.
4 | ---
5 |
6 |
7 | Javascript Objects
8 |
9 |
10 | JavaScript objects are containers for named values, called properties and methods.
11 |
12 |
13 |
14 | From the MDN Web Docs
15 |
16 |
17 | The Object type represents one of JavaScript's data types. It is used to store various keyed collections and more complex entities. Objects can be created using the Object() constructor or the object initializer / literal syntax.
18 |
19 |
20 |
21 | An example JavaScript object:
22 |
23 | ```javascript
24 | let car = {
25 | maker: "Toyota",
26 | model: "Camry",
27 | year: 2020,
28 | startEngine: function() {
29 | return "Engine started";
30 | }
31 | };
32 | ```
33 |
34 | `maker`, `model`, and `year` are properties of the `car` object, and `startEngine` is a method. You can access the properties using dot notation (e.g., `car.maker`) or bracket notation (e.g., `car["maker"]`), and you can call the method like this: `car.startEngine()`.
35 |
36 | ## Object Declaration
37 |
38 | You can declare an object in a few different ways:
39 |
40 | 1. **Object Literal Syntax**: This is the most common way to create an object in JavaScript. You simply define the property and value within curly braces `{}`.
41 |
42 | ```javascript
43 | let obj = {
44 | key1: 'value1',
45 | key2: 'value2',
46 | key3: 'value3'
47 | };
48 | ```
49 |
50 | 2. **Object Constructor**: This is another way to create an object but it's not as commonly used as the literal syntax.
51 |
52 | ```javascript
53 | let obj = new Object();
54 | obj.key1 = 'value1';
55 | obj.key2 = 'value2';
56 | obj.key3 = 'value3';
57 | ```
58 |
59 | 3. **Constructor Function**: If you need to create multiple objects with the same structure, you can use a constructor function.
60 |
61 | ```javascript
62 | function MyObject(key1, key2, key3) {
63 | this.key1 = key1;
64 | this.key2 = key2;
65 | this.key3 = key3;
66 | }
67 |
68 | let obj = new MyObject('value1', 'value2', 'value3');
69 | ```
70 |
71 | In all these examples, `obj` is an object with properties `key1`, `key2`, and `key3`.
72 |
73 | ## Object Properties
74 |
75 | You can read an object property using either `dot notation` or `bracket notation`.
76 |
77 | 1. **Dot Notation**:
78 |
79 | ```javascript
80 | let obj = {
81 | key1: 'value1',
82 | key2: 'value2',
83 | key3: 'value3'
84 | };
85 |
86 | console.log(obj.key1); // Outputs: 'value1'
87 | ```
88 |
89 | 2. **Bracket Notation**:
90 |
91 | ```javascript
92 | let obj = {
93 | key1: 'value1',
94 | key2: 'value2',
95 | key3: 'value3'
96 | };
97 |
98 | console.log(obj['key1']); // Outputs: 'value1'
99 | ```
100 |
101 | In both examples, we're reading the property `key1` from the object `obj`.
102 |
103 | ## Updating Object Properties
104 |
105 | Update the properties of an object using either `dot notation` or `bracket notation`.
106 |
107 | 1. **Dot Notation**:
108 |
109 | ```javascript
110 | let obj = {
111 | key1: 'value1',
112 | key2: 'value2',
113 | key3: 'value3'
114 | };
115 |
116 | obj.key1 = 'new value1';
117 | console.log(obj.key1); // Outputs: 'new value1'
118 | ```
119 |
120 | 2. **Bracket Notation**:
121 |
122 | ```javascript
123 | let obj = {
124 | key1: 'value1',
125 | key2: 'value2',
126 | key3: 'value3'
127 | };
128 |
129 | obj['key1'] = 'new value1';
130 | console.log(obj['key1']); // Outputs: 'new value1'
131 | ```
132 |
133 | In both cases, we're updating the property `key1` of the object `obj` to a new value.
134 |
135 | ## Adding Object Properties
136 |
137 | Add properties to an object after it has been created. This can be done using either `dot notation` or `bracket notation`.
138 |
139 | 1. **Dot Notation**:
140 |
141 | ```javascript
142 | let obj = {
143 | key1: 'value1',
144 | key2: 'value2'
145 | };
146 |
147 | obj.key3 = 'value3';
148 | console.log(obj.key3); // Outputs: 'value3'
149 | ```
150 |
151 | 2. **Bracket Notation**:
152 |
153 | ```javascript
154 | let obj = {
155 | key1: 'value1',
156 | key2: 'value2'
157 | };
158 |
159 | obj['key3'] = 'value3';
160 | console.log(obj['key3']); // Outputs: 'value3'
161 | ```
162 |
163 | In both examples, we're adding a new property `key3` to the object `obj`.
164 |
165 | ## Deleting Object Properties
166 |
167 | In JavaScript, you can delete properties from an object using the `delete` operator:
168 |
169 | ```javascript
170 | let obj = {
171 | key1: 'value1',
172 | key2: 'value2',
173 | key3: 'value3'
174 | };
175 |
176 | delete obj.key1;
177 | console.log(obj.key1); // Outputs: undefined
178 | ```
179 |
180 | We're deleting the property `key1` from the object `obj`. After the deletion, when we try to access `obj.key1`, it returns `undefined` because the property no longer exists.
181 |
182 | ## Checking if a Property Exists
183 |
184 | You can check if a property exists in an object using several methods:
185 |
186 | 1. **The `in` operator**: This returns `true` if the property exists in the object.
187 |
188 | ```javascript
189 | let obj = {
190 | key1: 'value1',
191 | key2: 'value2'
192 | };
193 |
194 | console.log('key1' in obj); // Outputs: true
195 | console.log('key3' in obj); // Outputs: false
196 | ```
197 |
198 | 2. **The `hasOwnProperty` method**: This returns `true` if the object has the specified property as its own property (not inherited).
199 |
200 | ```javascript
201 | let obj = {
202 | key1: 'value1',
203 | key2: 'value2'
204 | };
205 |
206 | console.log(obj.hasOwnProperty('key1')); // Outputs: true
207 | console.log(obj.hasOwnProperty('key3')); // Outputs: false
208 | ```
209 |
210 | 3. **Direct property access**: This checks if the property value is `undefined`. However, this method can give false negatives if the property exists but its value is set to `undefined`.
211 |
212 | ```javascript
213 | let obj = {
214 | key1: 'value1',
215 | key2: 'value2'
216 | };
217 |
218 | console.log(obj.key1 !== undefined); // Outputs: true
219 | console.log(obj.key3 !== undefined); // Outputs: false
220 | ```
221 |
222 | ## Iterating Over Object Properties
223 |
224 | Iterate over an object's properties using a `for...in` loop.
225 |
226 | ```javascript
227 | let obj = {
228 | key1: 'value1',
229 | key2: 'value2',
230 | key3: 'value3'
231 | };
232 |
233 | for (let key in obj) {
234 | if (obj.hasOwnProperty(key)) {
235 | console.log(key + ': ' + obj[key]);
236 | }
237 | }
238 | ```
239 |
240 | The `for...in` loop iterates over each property in the object `obj`. The `hasOwnProperty` method is used to ensure that the property belongs to the object itself and not its prototype chain. The output will be:
241 |
242 | ```
243 | key1: value1
244 | key2: value2
245 | key3: value3
246 | ```
247 |
248 | ## Object Methods
249 |
250 | Objects can have methods. Methods are functions that are stored as object properties.
251 |
252 | ```javascript
253 | let obj = {
254 | property1: 'value1',
255 | property2: 'value2',
256 | myMethod: function() {
257 | console.log('This is a method!');
258 | }
259 | };
260 |
261 | // Call the method
262 | obj.myMethod(); // Outputs: 'This is a method!'
263 | ```
264 |
265 | `myMethod` is a method of the object `obj`. You can call it using the object name followed by the method name.
266 |
267 | You can also use the `this` keyword in methods to refer to the object:
268 |
269 | ```javascript
270 | let obj = {
271 | property1: 'value1',
272 | property2: 'value2',
273 | myMethod: function() {
274 | console.log('Property1 is ' + this.property1);
275 | }
276 | };
277 |
278 | // Call the method
279 | obj.myMethod(); // Outputs: 'Property1 is value1'
280 | ```
281 |
282 | `this.property1` within the method refers to the `property1` of the object `obj`.
283 |
--------------------------------------------------------------------------------
/docs/cheatsheet/sets.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Javascript Sets - Javascript Cheatsheet
3 | description: A set is a built-in object that stores unique values of any type, whether primitive values or object references.
4 | ---
5 |
6 |
7 | Javascript Sets
8 |
9 |
10 | Sets are commonly used in scenarios where you need to work with collections of unique elements.
11 |
12 |
13 |
14 | From the MDN Web Docs
15 |
16 |
17 | The Set object lets you store unique values of any type, whether primitive values or object references.
18 |
19 |
20 |
21 | ## Common Use Cases
22 |
23 | ### Removing duplicates from an array
24 |
25 | Since a Set automatically removes duplicates, you can convert an array to a Set and back to an array to remove duplicate elements.
26 |
27 | ```javascript
28 | let array = [1, 2, 2, 3, 4, 4, 5];
29 | let uniqueArray = [...new Set(array)];
30 | console.log(uniqueArray); // Outputs: [1, 2, 3, 4, 5]
31 | ```
32 |
33 | ### Membership check
34 |
35 | Checking if an element exists in a Set is faster and more efficient than checking if it exists in an array.
36 |
37 | ```javascript
38 | let mySet = new Set([1, 2, 3, 4, 5]);
39 | console.log(mySet.has(3)); // Outputs: true
40 | ```
41 |
42 | ### Set operations
43 |
44 | You can perform operations like union, intersection, difference, and symmetric difference on Sets, similar to mathematical set operations.
45 |
46 |
47 |
48 | Remember!
49 |
50 |
51 | Sets only store unique values, so they are not suitable for cases where duplicate values are important.
52 |
53 |
54 |
55 | ## Set Declaration
56 |
57 | A Set is declared using the `new Set()` constructor. You can optionally pass an iterable (like an array) to the constructor to initialize the Set with values.
58 |
59 | ```javascript
60 | // Declare an empty Set
61 | let set1 = new Set();
62 |
63 | // Declare a Set with initial values
64 | let set2 = new Set([1, 2, 3, 4, 5]);
65 |
66 | console.log(set1); // Outputs: Set(0) {}
67 | console.log(set2); // Outputs: Set(5) { 1, 2, 3, 4, 5 }
68 | ```
69 |
70 | `set1` is an empty Set, and `set2` is a Set initialized with the values 1, 2, 3, 4, and 5. Note that Sets automatically remove duplicate values, so each value in a Set is unique.
71 |
72 | ## Checking if a Value Exists
73 |
74 | You can check if a value exists in a Set using the `has` method. The `has` method returns a boolean indicating whether the value exists in the Set:
75 |
76 | ```javascript
77 | let mySet = new Set([1, 2, 3, 4, 5]);
78 |
79 | console.log(mySet.has(1)); // Outputs: true
80 | console.log(mySet.has(6)); // Outputs: false
81 | ```
82 |
83 | `mySet` is a Set initialized with the values 1, 2, 3, 4, and 5. The `has` method is used to check if the values 1 and 6 exist in the Set.
84 |
85 | ## Adding and Deleting Values
86 |
87 | Add and delete values in a Set using the `add` and `delete` methods respectively.
88 |
89 | ### Adding Values
90 |
91 | You can add a value to a Set using the `add` method. The `add` method appends a new element with a specified value to the end of a Set object.
92 |
93 | ```javascript
94 | let mySet = new Set();
95 |
96 | mySet.add(1);
97 | mySet.add(2);
98 | mySet.add(3);
99 |
100 | console.log(mySet); // Outputs: Set(3) { 1, 2, 3 }
101 | ```
102 |
103 | Here, we're adding the values 1, 2, and 3 to the Set `mySet`.
104 |
105 | ### Deleting Values
106 |
107 | You can delete a value from a Set using the `delete` method. The `delete` method removes the specified element from a Set.
108 |
109 | ```javascript
110 | let mySet = new Set([1, 2, 3]);
111 |
112 | mySet.delete(2);
113 |
114 | console.log(mySet); // Outputs: Set(2) { 1, 3 }
115 | ```
116 |
117 | We're deleting the value 2 from the Set `mySet`.
118 |
119 | ## Getting the Size of a Set
120 |
121 | Get the size (number of elements) of a Set using the `size` property.
122 |
123 | ```javascript
124 | let mySet = new Set([1, 2, 3, 4, 5]);
125 |
126 | console.log(mySet.size); // Outputs: 5
127 | ```
128 |
129 | `mySet` is a Set initialized with the values 1, 2, 3, 4, and 5. The `size` property is used to get the number of elements in the Set.
130 |
131 | ## Iterating Over a Set
132 |
133 | You can iterate over a Set using several methods:
134 |
135 | 1. **For...of loop**: Iterate over the values in a Set.
136 |
137 | ```javascript
138 | let mySet = new Set([1, 2, 3, 4, 5]);
139 |
140 | for (let value of mySet) {
141 | console.log(value);
142 | }
143 | ```
144 |
145 | 2. **forEach method**: This allows you to execute a function for each value in a Set.
146 |
147 | ```javascript
148 | let mySet = new Set([1, 2, 3, 4, 5]);
149 |
150 | mySet.forEach(function(value) {
151 | console.log(value);
152 | });
153 | ```
154 |
155 | 3. **Spread operator**: Convert a Set into an Array, which can be useful for iteration.
156 |
157 | ```javascript
158 | let mySet = new Set([1, 2, 3, 4, 5]);
159 | let array = [...mySet];
160 |
161 | array.forEach(function(value) {
162 | console.log(value);
163 | });
164 | ```
165 |
166 | In each of these examples, we're iterating over the Set `mySet` and logging each value to the console.
167 |
168 | ## Clearing a Set
169 |
170 | In JavaScript, you can clear all values from a Set using the `clear` method.
171 |
172 | ```javascript
173 | let mySet = new Set([1, 2, 3, 4, 5]);
174 |
175 | console.log(mySet.size); // Outputs: 5
176 |
177 | mySet.clear();
178 |
179 | console.log(mySet.size); // Outputs: 0
180 | ```
181 |
182 | `mySet` is a Set initialized with the values 1, 2, 3, 4, and 5. The `clear` method is used to remove all values from the Set. After clearing, the size of the Set is 0.
183 |
184 | In JavaScript, you can perform set operations like union, intersection, difference, and symmetric difference using Sets. Here's how you can do it:
185 |
186 | ## Set Union
187 |
188 | The union of two sets is a set of all elements from both sets. You can get the union of two sets by creating a new Set from the concatenation of the two sets.
189 |
190 | ```javascript
191 | let setA = new Set([1, 2, 3]);
192 | let setB = new Set([3, 4, 5]);
193 |
194 | let union = new Set([...setA, ...setB]);
195 | console.log([...union]); // Outputs: [1, 2, 3, 4, 5]
196 | ```
197 |
198 | ## Set Intersection
199 |
200 | The intersection of two sets is a set of elements that are common to both sets. You can get the intersection of two sets by filtering one set for elements that also exist in the other set.
201 |
202 | ```javascript
203 | let setA = new Set([1, 2, 3]);
204 | let setB = new Set([3, 4, 5]);
205 |
206 | let intersection = new Set([...setA].filter(x => setB.has(x)));
207 | console.log([...intersection]); // Outputs: [3]
208 | ```
209 |
210 | ## Set Difference
211 |
212 | The difference of two sets is a set of elements that exist in the first set but not in the second set. You can get the difference of two sets by filtering the first set for elements that do not exist in the second set.
213 |
214 | ```javascript
215 | let setA = new Set([1, 2, 3]);
216 | let setB = new Set([3, 4, 5]);
217 |
218 | let difference = new Set([...setA].filter(x => !setB.has(x)));
219 | console.log([...difference]); // Outputs: [1, 2]
220 | ```
221 |
222 | ## Set Symmetric Difference
223 |
224 | The symmetric difference of two sets is a set of elements that exist in either of the two sets but not in their intersection. You can get the symmetric difference of two sets by getting the union of the two sets and then filtering out the intersection.
225 |
226 | ```javascript
227 | let setA = new Set([1, 2, 3]);
228 | let setB = new Set([3, 4, 5]);
229 |
230 | let union = new Set([...setA, ...setB]);
231 | let intersection = new Set([...setA].filter(x => setB.has(x)));
232 |
233 | let symmetricDifference = new Set([...union].filter(x => !intersection.has(x)));
234 | console.log([...symmetricDifference]); // Outputs: [1, 2, 4, 5]
235 | ```
--------------------------------------------------------------------------------
/docs/cheatsheet/string-formatting.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Javascript String Formatting - Javascript Cheatsheet
3 | description: In JavaScript, string formatting can be achieved in several ways. One common method is using template literals.
4 | ---
5 |
6 |
7 | Javascript String Formatting
8 |
9 |
10 | ## Template Literals
11 |
12 | **Template literals** (also known as template strings) are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them. They were introduced in ECMAScript 6.
13 |
14 |
15 |
16 | From the MDN Web Docs
17 |
18 |
19 | Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded expressions, and special constructs called tagged templates.
20 |
21 |
22 |
23 | Template literals can contain placeholders, indicated by the dollar sign and curly braces (`${expression}`). The expressions in the placeholders and the text between them get passed to a function.
24 |
25 | ```javascript
26 | let name = "John";
27 | let age = 30;
28 | let greeting = `Hello, my name is ${name} and I am ${age} years old.`;
29 |
30 | console.log(greeting); // Outputs: "Hello, my name is John and I am 30 years old."
31 | ```
32 |
33 | Here, `name` and `age` are variables. The template literal is defined using backticks, and the variables are embedded in the string using `${}` syntax. The resulting string is stored in the `greeting` variable and then logged to the console.
34 |
35 | ## String Concatenation
36 |
37 | String concatenation is the operation of joining two or more strings together. This can be achieved using the `+` operator or the `concat` method.
38 |
39 | ### Using the `+` Operator
40 |
41 | Here's an example of string concatenation using the `+` operator:
42 |
43 | ```javascript
44 | let str1 = "Hello, ";
45 | let str2 = "World!";
46 | let result = str1 + str2;
47 |
48 | console.log(result); // Outputs: "Hello, World!"
49 | ```
50 |
51 | `str1` and `str2` are strings. The `+` operator is used to concatenate `str1` and `str2` together. The resulting string is stored in the `result` variable and then logged to the console.
52 |
53 | ### Using the `concat` Method
54 |
55 | Here's an example of string concatenation using the `concat` method:
56 |
57 | ```javascript
58 | let str1 = "Hello, ";
59 | let str2 = "World!";
60 | let result = str1.concat(str2);
61 |
62 | console.log(result); // Outputs: "Hello, World!"
63 | ```
64 |
65 | `str1` and `str2` are strings. The `concat` method is called on `str1` with `str2` as the argument, concatenating `str1` and `str2` together. The resulting string is stored in the `result` variable and then logged to the console.
66 |
67 | ## The recommended way
68 |
69 | The recommended way to format strings in JavaScript is by using Template Literals (Template Strings) introduced in ECMAScript 6 (ES6). Template literals allow you to embed expressions, create multi-line strings, and use string interpolation features, making them a powerful tool for string formatting.
70 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/netlify.toml:
--------------------------------------------------------------------------------
1 | [build.environment]
2 | # bypass npm auto install
3 | NPM_FLAGS = "--version"
4 | NODE_VERSION = "16"
5 |
6 | [build]
7 | publish = "dist"
8 | command = "npx pnpm i --store=node_modules/.pnpm-store && npx pnpm run build"
9 |
10 | [[redirects]]
11 | from = "/*"
12 | to = "/index.html"
13 | status = 200
14 |
15 | [[headers]]
16 | for = "/manifest.webmanifest"
17 | [headers.values]
18 | Content-Type = "application/manifest+json"
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "vite",
5 | "build": "vite-ssg build",
6 | "preview": "vite preview",
7 | "test": "vitest --run",
8 | "lint": "eslint .",
9 | "typecheck": "vue-tsc --noEmit",
10 | "fetch-contributors": "esno scripts/fetch-contributors.ts"
11 | },
12 | "dependencies": {
13 | "@docsearch/js": "^3.8.0",
14 | "@headlessui/vue": "^1.7.23",
15 | "@vueuse/core": "^10.11.1",
16 | "@vueuse/head": "^2.0.0",
17 | "pinia": "^2.2.6",
18 | "prism-theme-vars": "^0.2.5",
19 | "vue": "^3.5.13",
20 | "vue-router": "^4.4.5"
21 | },
22 | "devDependencies": {
23 | "@tailwindcss/forms": "^0.5.9",
24 | "@tailwindcss/typography": "^0.5.15",
25 | "@types/fs-extra": "^11.0.4",
26 | "@types/markdown-it": "^14.1.2",
27 | "@types/markdown-it-link-attributes": "^3.0.5",
28 | "@types/node": "^22.9.0",
29 | "@types/string": "0.0.34",
30 | "@typescript-eslint/eslint-plugin": "^8.14.0",
31 | "@typescript-eslint/parser": "^8.14.0",
32 | "@vitejs/plugin-vue": "^5.2.0",
33 | "@vue/compiler-dom": "3.4.35",
34 | "@vue/test-utils": "^2.4.6",
35 | "autoprefixer": "^10.4.20",
36 | "esbuild": "^0.23.1",
37 | "eslint": "^9.15.0",
38 | "eslint-config-prettier": "^9.1.0",
39 | "eslint-plugin-vue": "^9.31.0",
40 | "esno": "^4.8.0",
41 | "fs-extra": "^11.2.0",
42 | "happy-dom": "^14.12.3",
43 | "markdown-it": "^14.1.0",
44 | "markdown-it-anchor": "^9.2.0",
45 | "markdown-it-link-attributes": "^4.0.1",
46 | "markdown-it-prism": "^2.3.0",
47 | "ofetch": "^1.4.1",
48 | "postcss": "^8.4.49",
49 | "prettier": "^3.3.3",
50 | "prettier-plugin-tailwindcss": "^0.6.8",
51 | "prismjs": "^1.29.0",
52 | "string": "^3.3.3",
53 | "tailwindcss": "^3.4.15",
54 | "typescript": "^5.6.3",
55 | "unplugin-auto-import": "^0.18.4",
56 | "unplugin-vue-components": "^0.27.4",
57 | "unplugin-vue-markdown": "^0.26.2",
58 | "vite": "^5.4.11",
59 | "vite-plugin-pages": "^0.32.3",
60 | "vite-plugin-pwa": "^0.20.5",
61 | "vite-plugin-vue-layouts": "^0.11.0",
62 | "vite-ssg": "^0.23.8",
63 | "vite-ssg-sitemap": "^0.6.1",
64 | "vitest": "^2.1.5",
65 | "vue-tsc": "^2.1.10"
66 | },
67 | "pnpm": {
68 | "peerDependencyRules": {
69 | "ignoreMissing": [
70 | "@algolia/client-search",
71 | "react",
72 | "react-dom",
73 | "@types/react"
74 | ]
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | }
7 |
--------------------------------------------------------------------------------
/public/_headers:
--------------------------------------------------------------------------------
1 | /assets/*
2 | cache-control: max-age=31536000
3 | cache-control: immutable
4 |
--------------------------------------------------------------------------------
/public/_redirects:
--------------------------------------------------------------------------------
1 | /api/* https://api.curated.co/api/v3/:splat 200
2 | /_ /index.html 200
3 | /\* /index.html 404
--------------------------------------------------------------------------------
/public/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/android-chrome-192x192.png
--------------------------------------------------------------------------------
/public/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/android-chrome-512x512.png
--------------------------------------------------------------------------------
/public/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/apple-touch-icon.png
--------------------------------------------------------------------------------
/public/browserconfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | #da532c
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/public/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/favicon-16x16.png
--------------------------------------------------------------------------------
/public/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/favicon-32x32.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/favicon.ico
--------------------------------------------------------------------------------
/public/fonts/Inter-italic.var.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/fonts/Inter-italic.var.woff2
--------------------------------------------------------------------------------
/public/fonts/Inter-roman.var.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/fonts/Inter-roman.var.woff2
--------------------------------------------------------------------------------
/public/fonts/lexend.txt:
--------------------------------------------------------------------------------
1 | Copyright 2018 The Lexend Project Authors (https://github.com/googlefonts/lexend), with Reserved Font Name “RevReading Lexend”.
2 |
3 | This Font Software is licensed under the SIL Open Font License, Version 1.1.
4 | This license is copied below, and is also available with a FAQ at:
5 | https://scripts.sil.org/OFL
6 |
7 |
8 | -----------------------------------------------------------
9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10 | -----------------------------------------------------------
11 |
12 | PREAMBLE
13 | The goals of the Open Font License (OFL) are to stimulate worldwide
14 | development of collaborative font projects, to support the font creation
15 | efforts of academic and linguistic communities, and to provide a free and
16 | open framework in which fonts may be shared and improved in partnership
17 | with others.
18 |
19 | The OFL allows the licensed fonts to be used, studied, modified and
20 | redistributed freely as long as they are not sold by themselves. The
21 | fonts, including any derivative works, can be bundled, embedded,
22 | redistributed and/or sold with any software provided that any reserved
23 | names are not used by derivative works. The fonts and derivatives,
24 | however, cannot be released under any other type of license. The
25 | requirement for fonts to remain under this license does not apply
26 | to any document created using the fonts or their derivatives.
27 |
28 | DEFINITIONS
29 | "Font Software" refers to the set of files released by the Copyright
30 | Holder(s) under this license and clearly marked as such. This may
31 | include source files, build scripts and documentation.
32 |
33 | "Reserved Font Name" refers to any names specified as such after the
34 | copyright statement(s).
35 |
36 | "Original Version" refers to the collection of Font Software components as
37 | distributed by the Copyright Holder(s).
38 |
39 | "Modified Version" refers to any derivative made by adding to, deleting,
40 | or substituting -- in part or in whole -- any of the components of the
41 | Original Version, by changing formats or by porting the Font Software to a
42 | new environment.
43 |
44 | "Author" refers to any designer, engineer, programmer, technical
45 | writer or other person who contributed to the Font Software.
46 |
47 | PERMISSION & CONDITIONS
48 | Permission is hereby granted, free of charge, to any person obtaining
49 | a copy of the Font Software, to use, study, copy, merge, embed, modify,
50 | redistribute, and sell modified and unmodified copies of the Font
51 | Software, subject to the following conditions:
52 |
53 | 1) Neither the Font Software nor any of its individual components,
54 | in Original or Modified Versions, may be sold by itself.
55 |
56 | 2) Original or Modified Versions of the Font Software may be bundled,
57 | redistributed and/or sold with any software, provided that each copy
58 | contains the above copyright notice and this license. These can be
59 | included either as stand-alone text files, human-readable headers or
60 | in the appropriate machine-readable metadata fields within text or
61 | binary files as long as those fields can be easily viewed by the user.
62 |
63 | 3) No Modified Version of the Font Software may use the Reserved Font
64 | Name(s) unless explicit written permission is granted by the corresponding
65 | Copyright Holder. This restriction only applies to the primary font name as
66 | presented to the users.
67 |
68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69 | Software shall not be used to promote, endorse or advertise any
70 | Modified Version, except to acknowledge the contribution(s) of the
71 | Copyright Holder(s) and the Author(s) or with their explicit written
72 | permission.
73 |
74 | 5) The Font Software, modified or unmodified, in part or in whole,
75 | must be distributed entirely under this license, and must not be
76 | distributed under any other license. The requirement for fonts to
77 | remain under this license does not apply to any document created
78 | using the Font Software.
79 |
80 | TERMINATION
81 | This license becomes null and void if any of the above conditions are
82 | not met.
83 |
84 | DISCLAIMER
85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93 | OTHER DEALINGS IN THE FONT SOFTWARE.
94 |
--------------------------------------------------------------------------------
/public/fonts/lexend.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/fonts/lexend.woff2
--------------------------------------------------------------------------------
/public/googleccbf6035fc9d727f.html:
--------------------------------------------------------------------------------
1 | google-site-verification: googleccbf6035fc9d727f.html
--------------------------------------------------------------------------------
/public/icons/favicon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/icons/javascript_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/icons/javascript_logo.png
--------------------------------------------------------------------------------
/public/mstile-144x144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/mstile-144x144.png
--------------------------------------------------------------------------------
/public/mstile-150x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/mstile-150x150.png
--------------------------------------------------------------------------------
/public/mstile-310x150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/mstile-310x150.png
--------------------------------------------------------------------------------
/public/mstile-310x310.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/mstile-310x310.png
--------------------------------------------------------------------------------
/public/mstile-70x70.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/mstile-70x70.png
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Allow: /
--------------------------------------------------------------------------------
/public/safari-pinned-tab.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/screenshots/capture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/screenshots/capture.png
--------------------------------------------------------------------------------
/public/site.webmanifest:
--------------------------------------------------------------------------------
1 | {"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
--------------------------------------------------------------------------------
/public/snake.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/social/social_banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/social/social_banner.png
--------------------------------------------------------------------------------
/public/sponsors/kinsta/SVG/PythonCheatSheet_banner_button-main.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/public/sponsors/kinsta/SVG/PythonCheatSheet_banner_kinsta_logo.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/public/sponsors/kinsta/SVG/kinsta-mobile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/sponsors/kinsta/SVG/kinsta-mobile.png
--------------------------------------------------------------------------------
/public/sponsors/kinsta/kinsta-logo-alpha-purple.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/sponsors/kinsta/kinsta-logo-alpha-purple.png
--------------------------------------------------------------------------------
/public/sponsors/kinsta/kinsta-logo-alpha-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/sponsors/kinsta/kinsta-logo-alpha-white.png
--------------------------------------------------------------------------------
/public/sponsors/kinsta/kinsta-logo1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/sponsors/kinsta/kinsta-logo1.png
--------------------------------------------------------------------------------
/public/sponsors/kinsta/kinsta-logo2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/sponsors/kinsta/kinsta-logo2.png
--------------------------------------------------------------------------------
/public/sponsors/kinsta/kinsta-logo3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/sponsors/kinsta/kinsta-logo3.png
--------------------------------------------------------------------------------
/public/sponsors/practity/practity.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/sponsors/practity/practity.webp
--------------------------------------------------------------------------------
/public/user-avatars/CodeWithBishal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/user-avatars/CodeWithBishal.png
--------------------------------------------------------------------------------
/public/user-avatars/Harish-clb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/user-avatars/Harish-clb.png
--------------------------------------------------------------------------------
/public/user-avatars/KamleshPandey98.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/user-avatars/KamleshPandey98.png
--------------------------------------------------------------------------------
/public/user-avatars/Kishore007raj.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/user-avatars/Kishore007raj.png
--------------------------------------------------------------------------------
/public/user-avatars/chrishenderson07.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/user-avatars/chrishenderson07.png
--------------------------------------------------------------------------------
/public/user-avatars/engtuncay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/user-avatars/engtuncay.png
--------------------------------------------------------------------------------
/public/user-avatars/gritgary101.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/user-avatars/gritgary101.png
--------------------------------------------------------------------------------
/public/user-avatars/hcz1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/user-avatars/hcz1.png
--------------------------------------------------------------------------------
/public/user-avatars/wilfredinni.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/public/user-avatars/wilfredinni.png
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:base"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/scripts/fetch-avatars.ts:
--------------------------------------------------------------------------------
1 | import { join, resolve } from 'pathe'
2 | import fs from 'fs-extra'
3 | import { ofetch } from 'ofetch'
4 |
5 | const docsDir = resolve(__dirname, '../')
6 | const pathContributors = resolve(docsDir, 'contributors/contributors.json')
7 | const dirAvatars = resolve(docsDir, 'public/user-avatars/')
8 |
9 | let contributors: string[] = []
10 |
11 | async function download(url: string, fileName: string) {
12 | try {
13 | console.log('downloading', fileName)
14 | const image = await ofetch(url, { responseType: 'arrayBuffer' })
15 | await fs.writeFile(fileName, Buffer.from(image))
16 | } catch (e) {
17 | console.log('error downloading', fileName)
18 | }
19 | }
20 |
21 | export async function fetchAvatars() {
22 | await fs.ensureDir(dirAvatars)
23 | contributors = JSON.parse(
24 | await fs.readFile(pathContributors, { encoding: 'utf-8' }),
25 | )
26 |
27 | await Promise.all(
28 | contributors.map((name) =>
29 | download(
30 | `https://github.com/${name}.png?size=48`,
31 | join(dirAvatars, `${name}.png`),
32 | ),
33 | ),
34 | )
35 | }
36 |
--------------------------------------------------------------------------------
/scripts/fetch-contributors.ts:
--------------------------------------------------------------------------------
1 | import { promises as fs } from 'fs'
2 | import { ofetch } from 'ofetch'
3 | import { fetchAvatars } from './fetch-avatars'
4 |
5 | interface Contributor {
6 | login: string
7 | }
8 |
9 | async function fetchContributors(page = 1) {
10 | const collaborators: string[] = []
11 | const data =
12 | (await ofetch(
13 | `https://api.github.com/repos/wilfredinni/javascript-cheatsheet/contributors?per_page=100&page=1`,
14 | {
15 | method: 'get',
16 | headers: {
17 | 'content-type': 'application/json',
18 | },
19 | },
20 | )) || []
21 | collaborators.push(...data.map((i) => i.login))
22 | const index = collaborators.indexOf('renovate[bot]')
23 | if (index > -1) collaborators.splice(index, 1)
24 |
25 | if (data.length === 100) {
26 | collaborators.push(...(await fetchContributors(page + 1)))
27 | }
28 |
29 | return collaborators
30 | }
31 |
32 | async function generate() {
33 | const collaborators = await fetchContributors()
34 | await fs.writeFile(
35 | './contributors/contributors.json',
36 | JSON.stringify(collaborators, null, 2),
37 | 'utf8',
38 | )
39 | }
40 |
41 | const init = async () => {
42 | await generate()
43 | await fetchAvatars()
44 | }
45 |
46 | init()
47 |
--------------------------------------------------------------------------------
/src/App.vue:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
41 |
--------------------------------------------------------------------------------
/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wilfredinni/javascript-cheatsheet/b2a431369dc56650c27555578ec07276c64bfdf0/src/assets/logo.png
--------------------------------------------------------------------------------
/src/components.d.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable */
2 | // @ts-nocheck
3 | // Generated by unplugin-vue-components
4 | // Read more: https://github.com/vuejs/core/pull/3399
5 | export {}
6 |
7 | /* prettier-ignore */
8 | declare module 'vue' {
9 | export interface GlobalComponents {
10 | AlgoliaDocSearch: typeof import('./components/AlgoliaDocSearch.vue')['default']
11 | ArrowIcon: typeof import('./components/icons/ArrowIcon.vue')['default']
12 | BaseBadge: typeof import('./components/ui/BaseBadge.vue')['default']
13 | BaseBadgeNotice: typeof import('./components/ui/BaseBadgeNotice.vue')['default']
14 | BaseBadgeSecondary: typeof import('./components/ui/BaseBadgeSecondary.vue')['default']
15 | BaseBanner: typeof import('./components/ui/BaseBanner.vue')['default']
16 | BaseCustomizableLinkCard: typeof import('./components/ui/BaseCustomizableLinkCard.vue')['default']
17 | BaseDisclaimer: typeof import('./components/ui/disclaimer/BaseDisclaimer.vue')['default']
18 | BaseDisclaimerContent: typeof import('./components/ui/disclaimer/BaseDisclaimerContent.vue')['default']
19 | BaseDisclaimerTitle: typeof import('./components/ui/disclaimer/BaseDisclaimerTitle.vue')['default']
20 | BaseLinkCard: typeof import('./components/ui/BaseLinkCard.vue')['default']
21 | BasePagination: typeof import('./components/ui/BasePagination.vue')['default']
22 | BaseReaderMode: typeof import('./components/ui/BaseReaderMode.vue')['default']
23 | BaseTable: typeof import('./components/ui/table/BaseTable.vue')['default']
24 | BaseTableItem: typeof import('./components/ui/table/BaseTableItem.vue')['default']
25 | BaseTableRow: typeof import('./components/ui/table/BaseTableRow.vue')['default']
26 | BaseThemeToggle: typeof import('./components/ui/BaseThemeToggle.vue')['default']
27 | BaseTitle: typeof import('./components/ui/BaseTitle.vue')['default']
28 | BaseWarning: typeof import('./components/ui/warning/BaseWarning.vue')['default']
29 | BaseWarningContent: typeof import('./components/ui/warning/BaseWarningContent.vue')['default']
30 | BaseWarningTitle: typeof import('./components/ui/warning/BaseWarningTitle.vue')['default']
31 | BlogTitleHeader: typeof import('./components/BlogTitleHeader.vue')['default']
32 | BugIcon: typeof import('./components/icons/BugIcon.vue')['default']
33 | CarbonAds: typeof import('./components/CarbonAds.vue')['default']
34 | Contributors: typeof import('./components/Contributors.vue')['default']
35 | Dialog: typeof import('@headlessui/vue')['Dialog']
36 | DialogPanel: typeof import('@headlessui/vue')['DialogPanel']
37 | DialogTitle: typeof import('@headlessui/vue')['DialogTitle']
38 | EditIcon: typeof import('./components/icons/EditIcon.vue')['default']
39 | EmptySection: typeof import('./components/EmptySection.vue')['default']
40 | GithubIcon: typeof import('./components/icons/GithubIcon.vue')['default']
41 | GridIcon: typeof import('./components/icons/GridIcon.vue')['default']
42 | LightBulbIcon: typeof import('./components/icons/LightBulbIcon.vue')['default']
43 | NetlifyBadge: typeof import('./components/NetlifyBadge.vue')['default']
44 | NewBadge: typeof import('./components/ui/newBadge.vue')['default']
45 | PluginIcon: typeof import('./components/icons/PluginIcon.vue')['default']
46 | Prose: typeof import('./components/Prose.vue')['default']
47 | QuestionIcon: typeof import('./components/icons/QuestionIcon.vue')['default']
48 | ReferenceIcon: typeof import('./components/icons/ReferenceIcon.vue')['default']
49 | RouterLink: typeof import('vue-router')['RouterLink']
50 | RouterView: typeof import('vue-router')['RouterView']
51 | Switch: typeof import('@headlessui/vue')['Switch']
52 | TheFooter: typeof import('./components/layout/TheFooter.vue')['default']
53 | TheNavbar: typeof import('./components/layout/TheNavbar.vue')['default']
54 | TheNavbarReader: typeof import('./components/layout/TheNavbarReader.vue')['default']
55 | TheSidebarDesktop: typeof import('./components/layout/TheSidebarDesktop.vue')['default']
56 | TheSidebarMobile: typeof import('./components/layout/TheSidebarMobile.vue')['default']
57 | TheSidebarNavigation: typeof import('./components/layout/TheSidebarNavigation.vue')['default']
58 | TheToc: typeof import('./components/layout/TheToc.vue')['default']
59 | TransitionChild: typeof import('@headlessui/vue')['TransitionChild']
60 | TransitionRoot: typeof import('@headlessui/vue')['TransitionRoot']
61 | WarningIcon: typeof import('./components/icons/WarningIcon.vue')['default']
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/components/AlgoliaDocSearch.vue:
--------------------------------------------------------------------------------
1 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/src/components/BlogTitleHeader.vue:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
27 |
28 |
--------------------------------------------------------------------------------
/src/components/EmptySection.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | Ups! Nothing here yet!
4 |
5 | This is a great opportunity for you to collaborate! Hit the link at
6 | the end of this page and add some examples and a brief description. If you
7 | don't know where to start, the
8 | Javascript documentation
13 | will lead you in the right direction.
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/components/NetlifyBadge.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/components/Prose.vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
42 | Sorry, we couldn’t find the page you’re looking for.
43 |
44 |
45 |
49 | Go back home →
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | meta:
60 | layout: empty
61 |
62 |
--------------------------------------------------------------------------------
/src/pages/changelog.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 'Changelog - Javascript Cheatsheet'
3 | description: See what is new, what got fixed, and what is coming.
4 | date: July 19, 2022
5 | updated: February 25, 2023
6 | ---
7 |
8 |
9 | Changelog
10 |
11 |
12 | ## 2024-09-22
13 |
14 | - Added Javascript Map Objects. Thanks [@Harish-clb](https://github.com/Harish-clb)
15 | - Updated changelog.
16 | - Updated contributors.
17 | - Updated packages and dependencies.
18 |
19 | ## 2024-07-11
20 |
21 | - Added a missing operator in Bitwise operators. Thanks [@Kishore007raj](https://github.com/Kishore007raj)
22 | - Fixed missing style (DocSearch-VisuallyHiddenForAccessibility). Thanks [@gritgary101](https://github.com/gritgary101)
23 |
24 | ## 2024-01-29
25 |
26 | The release of the new **www.javascriptcheatsheet.org** website:
27 |
28 | - Complete re-design with **Vue 3** and **Tailwind CSS**.
29 | - The site is now a **PWA** and can be installed in any platform that has a compatible web browser.
30 | - Added a **dark mode**.
31 | - Added a **reader mode**.
32 | - Added **Algolia search**.
33 | - Added contributors to the index page 🥰
34 | - Added, fixed and removed code examples.
35 | - Added an **Edit this page on GitHub** link to make it easier to contribute.
36 | - Changed hosting to **Netlify** with an OSS plan 🎉
37 | - Removed and joined cheatsheet sections.
38 | - Fixed grammar and spelling mistakes.
39 |
--------------------------------------------------------------------------------
/src/pages/contributing.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 'Contributing - Javascript Cheatsheet'
3 | description: The following is a set of guidelines for contributing to the Javascript Cheatsheet. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document.
4 | date: June 09, 2018
5 | updated: July 3, 2022
6 | ---
7 |
8 |
9 | Contributing
10 |
11 |
12 | First off, thank you for taking the time to contribute!
13 |
14 | The following is a set of guidelines for contributing to the Javascript Cheatsheet. These are mostly guidelines, not rules. Use your best judgment, and please don't hesitate to propose changes to [this document](https://github.com/wilfredinni/javascript-cheatsheet/blob/master/src/pages/contributing.md).
15 |
16 | ## Code of Conduct
17 |
18 | This project and everyone who participates in it is governed by the [Contributor Covenant Code of Conduct](https://github.com/wilfredinni/javascript-cheatsheet/blob/master/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to services@github.com.
19 |
20 | ## Running the project locally
21 |
22 | 1. Install the [pnpm](https://pnpm.io/installation) package manager
23 |
24 | On Linux/macOS:
25 |
26 | curl -fsSL https://get.pnpm.io/install.sh | sh -
27 |
28 | On Windows (PowerShell):
29 |
30 | iwr https://get.pnpm.io/install.ps1 -useb | iex
31 |
32 | 2. Clone the project, and install the dependencies:
33 |
34 | git clone https://github.com/wilfredinni/javascript-cheatsheet.git
35 | cd javascript-cheatsheet
36 | pnpm install
37 |
38 | 3. Create a new branch:
39 |
40 | git branch fix_bug
41 | git checkout fix_bug
42 |
43 | 4. Change/upgrade/add the changes you want
44 | 5. Update the `README` if needed
45 | 6. `Add`, `commit` and `push` your changes to GitHub:
46 |
47 | git add .
48 | git commit -m 'succinct explanation of what changed'
49 | git push origin fix_bug
50 |
51 | 7. Open a [pull request](https://github.com/wilfredinni/javascript-cheatsheet/pulls)
52 |
53 | ## You can:
54 |
55 | - Submit changes to the cheatsheet
56 | - Improve existing topics and examples
57 | - Add new topics or resources
58 | - Ask for new topics by creating an [Issue](https://github.com/wilfredinni/javascript-cheatsheet/issues)
59 | - Read the issues, fork the project and do a [Pull Request](https://github.com/wilfredinni/javascript-cheatsheet/pulls)
60 | - Report any kind of error or typo by creating an [Issue](https://github.com/wilfredinni/javascript-cheatsheet/issues) or fix it with a [Pull Request](https://github.com/wilfredinni/javascript-cheatsheet/pulls)
61 |
62 | ## What you need to know
63 |
64 | If you don't know where to start:
65 |
66 | - [Mastering Markdown](https://guides.github.com/features/mastering-markdown/)
67 | - [Mastering Issues](https://guides.github.com/features/issues/)
68 | - [Forking Projects](https://guides.github.com/activities/forking/)
69 | - And read the rest of the [GitHub Guides](https://guides.github.com/)
70 |
--------------------------------------------------------------------------------
/src/pages/index.vue:
--------------------------------------------------------------------------------
1 |
40 |
41 |
42 |
43 |
44 |
45 |
52 |
53 |
54 |
60 |
Javascript Cheatsheet
61 |
62 |
66 | Javascript Cheatsheet
67 |
68 |
69 |
70 |
71 |
72 | Anyone can forget how to
73 |
76 | make character classes
77 |
78 | for a regex,
79 |
82 | slice a list
83 |
84 | or do a
85 |
86 | for loop
87 |
88 | . This Javascript Cheatsheet tries to provide basic reference for
89 | beginner and advanced developers, lower the entry barrier for newcomers
90 | and help veterans refresh the old tricks.
91 |