Skip to content

Commit 488007f

Browse files
committed
Module 6 Complete
1 parent 1269803 commit 488007f

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# The JavaScript Standard
2+
3+
JavaScript provides a rich standard library that empowers developers to work with data structures, patterns, APIs, and more. Here's an overview of key concepts and tools.
4+
5+
---
6+
7+
## Sets and Maps
8+
### Sets
9+
- A `Set` is a collection of unique values.
10+
- Example:
11+
12+
```javascript
13+
let set = new Set([1, 2, 3, 3]);
14+
console.log(set); // Set(3) {1, 2, 3}
15+
```
16+
- Common methods: `add()`, `delete()`, `has()`, `clear()`.
17+
18+
### Maps
19+
- A `Map` is a collection of key-value pairs.
20+
- Example:
21+
22+
```javascript
23+
let map = new Map();
24+
map.set('key', 'value');
25+
console.log(map.get('key')); // 'value'
26+
```
27+
- Common methods: `set()`, `get()`, `delete()`, `has()`, `clear()`.
28+
29+
---
30+
31+
## Typed Arrays and Binary Data
32+
Typed arrays provide efficient handling of binary data.
33+
- Example:
34+
35+
```javascript
36+
let buffer = new ArrayBuffer(16);
37+
let int32View = new Int32Array(buffer);
38+
int32View[0] = 42;
39+
console.log(int32View[0]); // 42
40+
```
41+
- Key classes: `ArrayBuffer`, `Uint8Array`, `Float32Array`.
42+
43+
---
44+
45+
## Pattern Matching with Regular Expressions
46+
Regular expressions are powerful tools for pattern matching and string manipulation.
47+
- Example:
48+
49+
```javascript
50+
let regex = /\d+/g;
51+
let matches = '123 abc 456'.match(regex);
52+
console.log(matches); // ['123', '456']
53+
```
54+
- Flags: `g` (global), `i` (case-insensitive), `m` (multiline).
55+
56+
---
57+
58+
## Dates and Times
59+
The `Date` object handles date and time.
60+
- Example:
61+
62+
```javascript
63+
let now = new Date();
64+
console.log(now.toISOString());
65+
```
66+
- Methods: `getFullYear()`, `getMonth()`, `getDate()`, `getTime()`.
67+
68+
---
69+
70+
## Error Classes
71+
Custom error classes extend JavaScript's built-in error handling.
72+
- Example:
73+
74+
```javascript
75+
class CustomError extends Error {
76+
constructor(message) {
77+
super(message);
78+
this.name = 'CustomError';
79+
}
80+
}
81+
throw new CustomError('Something went wrong');
82+
```
83+
84+
---
85+
86+
## JSON Serialization and Parsing
87+
Convert data to/from JSON format.
88+
- Example:
89+
90+
```javascript
91+
let obj = { key: 'value' };
92+
let json = JSON.stringify(obj);
93+
console.log(JSON.parse(json));
94+
```
95+
96+
---
97+
98+
## The Internationalization API
99+
Format numbers, dates, and strings for international contexts.
100+
- Example:
101+
102+
```javascript
103+
let number = 123456.789;
104+
let formatted = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(number);
105+
console.log(formatted); // $123,456.79
106+
```
107+
108+
---
109+
110+
## The Console API
111+
Provides tools for debugging and logging.
112+
- Example:
113+
114+
```javascript
115+
console.log('Log message');
116+
console.warn('Warning message');
117+
console.error('Error message');
118+
```
119+
120+
---
121+
122+
## URL APIs
123+
Manipulate URLs programmatically.
124+
- Example:
125+
126+
```javascript
127+
let url = new URL('https://example.com?key=value');
128+
console.log(url.searchParams.get('key')); // 'value'
129+
```
130+
131+
---
132+
133+
## Timers
134+
Execute code after a delay or repeatedly.
135+
- Example:
136+
137+
```javascript
138+
setTimeout(() => console.log('Hello after 1 second'), 1000);
139+
let interval = setInterval(() => console.log('Repeating every second'), 1000);
140+
clearInterval(interval);
141+
```
142+
143+
---
144+
145+
With these tools, JavaScript provides robust capabilities for building modern web applications.
146+

0 commit comments

Comments
 (0)