Skip to content

Commit

Permalink
adds more chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
ishtms committed Sep 22, 2023
1 parent af293d0 commit 4a53813
Show file tree
Hide file tree
Showing 49 changed files with 3,695 additions and 96 deletions.
Binary file added .DS_Store
Binary file not shown.
140 changes: 73 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,82 @@ You may also check out my other repository - [Learn Node.js - The Hard Way](http

## Table of Contents

1. [Variables](chapters/00_variables.js)
2. [Data Types](chapters/01_data_types.js)
3. [Type Conversion](chapters/02_type_conversion.js)
4. [Type Coercion](chapters/03_type_coercion.js)
5. [Operators](chapters/04_operators.js)
6. [Control Flow](chapters/05_control_flow.js)
7. [Loops](chapters/06_loops.js)
8. [Arrays](chapters/07_arrays.js)
9. [Strings](chapters/08_strings.js)
10. [Functions](chapters/09_functions.js)
11. [Scope](chapters/10_scope.js)
12. [Closure](chapters/11_closure.js)
13. [Objects](chapters/12_objects.js)
14. [Inheritance in Objects](chapters/13_inheritance_objects.js)
15. [Classes](chapters/14_classes.js)
16. [Inheritance in Classes](chapters/15_inheritance_classes.js)
17. [Destructuring](chapters/16_destructuring.js)
18. [Spread and Rest](chapters/17_spread_rest.js)
19. [This](chapters/18_this.js)
20. [Call, Apply, and Bind](chapters/19_call_apply_bind.js)
21. [Error Handling](chapters/20_error_handling.js)
22. [Debugging](chapters/21_debugging.js)
23. [Callbacks](chapters/22_callbacks.js)
24. [Promises](chapters/23_promises.js)
25. [Asynchronous Programming](chapters/24_asynchronous.js)
26. [DOM Manipulation](chapters/25_dom_manipulation.js)
27. [Events](chapters/26_events.js)
28. [Storage](chapters/27_storage.js)
29. [IndexedDB](chapters/28_indexed_db.js)
30. [Symbols](chapters/29_symbol.js)
31. [Fetch API](chapters/30_fetch.js)
32. [Modules](chapters/31_modules.js)
33. [Template Literals](chapters/32_template_literals.js)
34. [Date and Time](chapters/33_date_time.js)
35. [Math](chapters/34_math.js)
36. [Bitwise Operations](chapters/35_bitwise.js)
37. [Regular Expressions](chapters/36_regex.js)
38. [Performance Optimization](chapters/48_performance.js)
39. [Navigator API](chapters/49_navigator.js)
40. [User Timing API](chapters/50_user_timing_api.js)
41. [Navigation Timing API](chapters/51_navigation_timing.js)
1. [Variables](./chapters/00_variables.js)
2. [Data Types](./chapters/01_data_types.js)
3. [Type Conversion](./chapters/02_type_conversion.js)
4. [Type Coercion](./chapters/03_type_coercion.js)
5. [Operators](./chapters/04_operators.js)
- [Ternary Operator](./chapters/04.1_ternary.js)
- [Nullish Coalescing](./chapters/04.2_nullish_coalescing.js)
6. [Control Flow](./chapters/05_control_flow.js)
7. [Loops](./chapters/06_loops.js)
8. [Arrays](./chapters/07_arrays.js)
9. [Strings](./chapters/08_strings.js)
10. [Functions](./chapters/09_functions.js)
11. [Scope](./chapters/10_scope.js)
12. [Objects](./chapters/12_objects.js)
- [Error Object](./chapters/12.1_error_object.js)
- [Optional Chaining](./chapters/12.1_optional_chaining.js)
13. [Inheritance with Objects](./chapters/13_inheritance_objects.js)
14. [Classes](./chapters/14_classes.js)
15. [Inheritance with Classes](./chapters/15_inheritance_classes.js)
16. [Destructuring](./chapters/16_destructuring.js)
17. [Spread and Rest Operators](./chapters/17_spread_rest.js)
18. [`this` Keyword](./chapters/18_this.js)
19. [Call, Apply, Bind](./chapters/19_call_apply_bind.js)
20. [Error Handling](./chapters/20_error_handling.js)
21. [Debugging](./chapters/21_debugging.js)
22. [Callbacks](./chapters/22_callbacks.js)
23. [Promises](./chapters/23_promises.js)
- [Async/Await](./chapters/23.1_async_await.js)
24. [Asynchronous Programming](./chapters/24_asynchronous.js)
25. [DOM Manipulation](./chapters/25_dom_manipulation.js)
26. [Events](./chapters/26_events.js)
27. [Storage](./chapters/27_storage.js)
28. [IndexedDB](./chapters/28_indexed_db.js)
29. [Symbol](./chapters/29_symbol.js)
30. [Fetch API](./chapters/30_fetch.js)
31. [Modules](./chapters/31_modules.js)
32. [Template Literals](./chapters/32_template_literals.js)
33. [Date and Time](./chapters/33_date_time.js)
34. [Math](./chapters/34_math.js)
35. [Bitwise Operations](./chapters/35_bitwise.js)
36. [Regular Expressions](./chapters/36_regex.js)
37. [`setTimeout`](./chapters/37_set_timeout.js)
38. [`setInterval`](./chapters/38_setInterval.js)
39. [`JSON.stringify`](./chapters/39_json_stringify.js)
40. [`JSON.parse`](./chapters/40_json_parse.js)
41. [Map](./chapters/41_map.js)
42. [WeakMap](./chapters/42_weak_map.js)
43. [Set](./chapters/43_set.js)
44. [WeakSet](./chapters/44_weak_map.js)
45. [Generators](./chapters/45_generators.js)
46. [Iterators](./chapters/46_iterators.js)
47. [BigInt](./chapters/47_big_int.js)
48. [Web APIs](./chapters/48.0_web_apis.js)
- [Web APIs 2](./chapters/48.1_web_apis_2.js)
- [Web APIs 3](./chapters/48.2_web_apis_3.js)
49. [Canvas](./chapters/49_canvas.js)
50. [Drag and Drop](./chapters/50_drag_drop.js)
51. [File and Blob](./chapters/51_file_and_blob.js)
52. [Websockets](./chapters/52_websockets.js)
53. [Web Workers](./chapters/53_web_workers.js)
54. [Service Workers](./chapters/54_service_workers.js)
55. [Custom Events](./chapters/55_custom_events.js)
56. [WebRTC](./chapters/56_webrtc.js)
57. [Dynamic Imports](./chapters/57_dynamic_imports.js)
58. [Decorators](./chapters/58_decorators.js)
59. [Proxy](./chapters/59_proxy.js)
60. [Reflect](./chapters/60_reflect.js)
61. [Performance](./chapters/61_performance.js)
62. [Navigator](./chapters/62_navigator.js)
63. [User Timing API](./chapters/63_user_timing_api.js)
64. [Navigation Timing](./chapters/64_navigation_timing.js)
65. [Lazy Loading](./chapters/65_lazy_loading.js)

## Additional Topics (To Be Added)

- `setTimeout()` and `setInterval()`
- `clearTimeout()` and `clearInterval()`
- `JSON.stringify()` and `JSON.parse()`
- `Map()`
- `Set()`
- `WeakMap()` and `WeakSet()`
- Generators
- Iterators
- `async/await`
- BigInt
- Web APIs (Window, Document)
- Canvas API
- Drag and Drop API
- File and Blob
- WebSockets
- Web Workers
- Service Workers
- Custom Events
- WebRTC
- LocalStorage, SessionStorage, and Cookies
- FormData
- Dynamic Import
- Decorators
- Proxy
- Reflect
- Memory Management
There are more complex topics that I would like to cover in this repository. I will be adding them as I get time to write them. Most of them will be related to performance and optimization.

## More chapters (on demand)

Expand Down
82 changes: 82 additions & 0 deletions chapters/04.1_ternary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* ========================================================
* Conditional (Ternary) Operator
* ========================================================
* The conditional (ternary) operator is a shorthand way to perform conditional (if-else-like) operations.
* The syntax is: condition ? expression1 : expression2
* If the condition is true, expression1 is executed, otherwise, expression2 is executed.
*/

/**
* ========================================================
* Basic Usage
* ========================================================
* In a simple example, you can use it to assign a value to a variable based on a condition.
*/
const isAdult = true;
const type = isAdult ? "Adult" : "Minor";
console.log(`Person is an: ${type}`); // Output: 'Person is an: Adult'

/**
* ========================================================
* Nested Ternary Operators
* ========================================================
* Ternary operators can be nested for multiple conditions, but this may reduce readability.
*/
const age = 25;
const ageGroup = age < 18 ? "Minor" : age < 60 ? "Adult" : "Senior";
console.log(`Age Group: ${ageGroup}`); // Output: 'Age Group: Adult'

/**
* ========================================================
* Using with Functions
* ========================================================
* You can also execute functions using the ternary operator.
*/
function greetMorning() {
return "Good Morning";
}

function greetEvening() {
return "Good Evening";
}

const isMorning = true;
console.log(isMorning ? greetMorning() : greetEvening()); // Output: 'Good Morning'

/**
* ========================================================
* As an Expression
* ========================================================
* The ternary operator is an expression, meaning it returns a value.
* You can use it inline with other operations.
*/
const score = 95;
console.log(`You ${score > 50 ? "passed" : "failed"} the exam.`); // Output: 'You passed the exam.'

/**
* ========================================================
* Nuances and Advanced Techniques
* ========================================================
*/

/**
* 1. Type Coercion
* ----------------
* Be cautious about type coercion when using the ternary operator, as it follows the same rules as other JavaScript operators.
*/
const value = "5";
const number = value == 5 ? "Loose equality" : "Strict inequality";
console.log(`Type Coercion: ${number}`); // Output: 'Loose equality'

/**
* 2. Avoid Side Effects
* ----------------------
* Avoid using ternary operators for operations that produce side effects, like assignments or function calls with side effects.
*/

/**
* 3. Readability
* --------------
* While chaining or nesting ternary operators can be powerful, it can also make code harder to read and maintain.
*/
Empty file.
2 changes: 1 addition & 1 deletion chapters/09_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function functions() {
function sayHello(name) {
return `Hello, ${name}`;
}
console.log(sayHello("Alice")); // Outputs: "Hello, Alice"
console.log(sayHello("Ishtmeet")); // Outputs: "Hello, Ishtmeet"

/**
* ========================================================
Expand Down
Loading

0 comments on commit 4a53813

Please sign in to comment.