Skip to content

Commit 64a8968

Browse files
add asynchronous operation
1 parent 01a0cb2 commit 64a8968

20 files changed

+537
-41
lines changed

13_function/3_array_with_function.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function handleArray(getArray) {
66
return getArray[1];
77
}
88

9-
// // Passing an array reference as a argument in the function.
9+
// Passing an array reference as a argument in the function.
1010
console.log(handleArray(myArray));
1111

1212
// Passing literally an array as a argument in the function.

19_Iterations/6_for_in_loop.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// Why
99
// - It can be useful for generic object property iteration, especially when you need to access property names and values for various purposes.
1010
// - It can simplify looping through object properties without requiring manual property access by name.
11+
1112
// How
1213
// - It works by cycling through the enumerable properties of an object, one by one.
1314
// - The loop body executes for each property, providing you with the property name (prop) in each iteration.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Asynchronous Operation
2+
3+
What
4+
5+
- An asynchronous operation is a process that starts but doesn't necessarily finish immediately.
6+
- It allows a program to continue executing other tasks while waiting for the operation to complete.
7+
8+
Why
9+
10+
- **Improved Performance:** Prevents the program from freezing while waiting for long-running tasks.
11+
- **Better User Experience:** Maintains responsiveness and allows users to interact with the application while background tasks are in progress.
12+
- **Efficient Resource Utilization:** Enables handling multiple tasks concurrently.
13+
14+
How
15+
16+
- When an asynchronous operation starts, it runs in the background. The program can continue executing other code while the operation is in progress.
17+
- Once the operation completes, a callback function or a promise is used to handle the result.
18+
19+
Example
20+
21+
- Fetching data from a server is a common asynchronous operation.
22+
- The code can continue executing other tasks while waiting for the data to be retrieved.
23+
- Once the data is available, a callback function is called to process it.
24+
25+
Important Note
26+
27+
- Asynchronous programming can introduce complexities like callbacks, promises, or async/await. Careful handling is required to manage asynchronous code effectively.
28+
29+
When
30+
31+
- Use asynchronous operations for tasks that are time-consuming or might block the program's execution, such as network requests, file I/O, or database operations.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Object
2+
3+
// Resource
4+
5+
// What
6+
// - Object is a data type in JavaScript that represents a complex data structure, such as arrays, functions, and custom objects.
7+
8+
// Why
9+
// - Objects help organize and structure data in a more flexible and efficient manner.
10+
// - They provide a way to encapsulate related properties and methods into a single entity.
11+
// - Objects enable the creation of reusable code and modular programming.
12+
13+
// How
14+
// - Objects are key-value pairs, where keys are unique identifiers and values can be of any data type.
15+
// - Objects can be created using object literals, constructor functions, or object-oriented programming techniques.
16+
17+
// Syntax
18+
// Object literal syntax
19+
const object = {
20+
key1: value1,
21+
key2: value2,
22+
};
23+
24+
// Constructor function syntax
25+
function MyObject() {
26+
this.key1 = value1;
27+
this.key2 = value2;
28+
}
29+
30+
const object1 = new MyObject();
31+
32+
// Example
33+
const person = {
34+
name: "John",
35+
age: 30,
36+
greet: function () {
37+
console.log(`Hello, my name is ${this.name}`);
38+
},
39+
};
40+
41+
console.log(person.name); // Output: John
42+
console.log(person.age); // Output: 30
43+
person.greet(); // Output: Hello, my name is John
44+
45+
// Note
46+
// - Objects are mutable, meaning their properties and methods can be changed after they are created.
47+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Array
2+
3+
// Resource
4+
5+
// What
6+
// - Array is a data type in JavaScript that represents a collection of elements, also known as a list or a sequence.
7+
8+
// Why
9+
// - Arrays provide a convenient way to store and organize multiple values in a single variable.
10+
// - They allow for efficient access, manipulation, and iteration over the elements.
11+
// - Arrays enable the creation of dynamic and flexible data structures.
12+
13+
// How
14+
// - Arrays are ordered collections of elements, where each element has a unique index.
15+
// - The index starts from 0 and can be used to access and modify elements in the array.
16+
// - Arrays can contain elements of any data type, including other arrays, objects, and functions.
17+
18+
// Syntax
19+
// Array literal syntax
20+
const array = [element1, element2, element3];
21+
22+
// Array constructor syntax
23+
const array1 = new Array(element1, element2, element3);
24+
25+
// Example
26+
const numbers = [1, 2, 3, 4, 5];
27+
console.log(numbers[0]); // Output: 1
28+
console.log(numbers[2]); // Output: 3
29+
30+
numbers[3] = 10;
31+
console.log(numbers); // Output: [1, 2, 3, 10, 5]
32+
33+
console.log(numbers.length); // Output: 5
34+
35+
// Note
36+
// - Arrays are mutable, meaning their elements can be changed after they are created.
37+
// - Arrays can be dynamically resized, allowing you to add or remove elements.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Topic
2+
3+
// Resource
4+
// What
5+
// - Function is a reusable block of code that performs a specific task or calculates a value.
6+
7+
// Why
8+
// - Functions help break down a program into smaller, more manageable pieces.
9+
// - They allow for code reuse, reducing redundancy and improving code readability.
10+
// - Functions enable modular programming, making it easier to maintain and debug code.
11+
12+
// How
13+
// - Functions are defined using the function keyword, followed by the function name and a set of parentheses.
14+
// - Inside the function, you can write code to perform the desired task or calculate a value.
15+
// - Functions can accept parameters, which are values passed into the function when it is called.
16+
// - Functions can return a value using the return statement.
17+
18+
// Syntax
19+
// Function Declaration
20+
function functionName(parameter1, parameter2) {
21+
return console.log("I am Function Declaration");
22+
}
23+
24+
// Function Expression
25+
const functionName = function (parameter1, parameter2) {
26+
return console.log("I am Function Expression");
27+
};
28+
29+
// Example
30+
function greet(name) {
31+
console.log(`Hello, ${name}!`);
32+
}
33+
34+
greet("John"); // Output: Hello, John!
35+
36+
function add(a, b) {
37+
return a + b;
38+
}
39+
40+
const result = add(2, 3);
41+
console.log(result); // Output: 5
42+
43+
// Note
44+
// - Functions in JavaScript are first-class objects, meaning they can be assigned to variables, passed as arguments to other functions, and returned as values from functions.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// `undefined`
2+
3+
// Resource
4+
5+
// What
6+
// -> Undefined is a data type in JavaScript that represents a variable that has not been assigned a value.
7+
8+
// Why
9+
// -> Undefined helps ensure that your program behaves correctly and handles different types of data appropriately.
10+
// -> It provides a foundation for writing robust and maintainable code.
11+
12+
// How
13+
// -> You can assign literally a value as undefined to a variable.
14+
// -> Declared variables without assigning any value also have an undefined value.
15+
16+
// Syntax
17+
let variableName1; // variable declared but not assigned any value
18+
let variableName2 = undefined; // variable assigned the value `undefined`
19+
20+
// Note
21+
// -> It is not recommended to explicitly assign the value undefined to a variable.
22+
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// `null`
2+
3+
// What
4+
// -> Null is standalone value. To understand this let say you are creating weather application which give you the temperature of selected city. For any reason server unable to send you the temperature that means there is no temperature value. At that case weather app shouldn't show `0` on screen. Because 0 also refer as temperature value. At that time we use null to show there is actually no temperature and server are unable to fetch data of temperature.
5+
6+
// Why
7+
// -> Null helps handle cases where a variable should have a value, but the value is currently not available or not applicable.
8+
// -> It provides a way to differentiate between an unassigned variable and a variable with a value of null.
9+
10+
// How
11+
// -> Null is a standalone value. It represents the absence of a value.
12+
// -> When checking the type of null using typeof, it will show object. This is a common misconception, as null is not an object.
13+
14+
// Syntax
15+
let variableName = null;
16+
17+
// Note
18+
// -> Null is often used to represent the absence of a value, such as when a function does not return a value or when an object is expected but not available.
19+
20+
// When
21+
// -> Use Null when you want to represent the absence of a value or when a variable should have a value of null.

5_datatype/1_datatype.js 5_datatype/datatype.js

-11
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@
1717
// - Undefined: Represents a variable that has not been assigned a value.
1818
// - Null: Represents a variable that has been explicitly assigned a value of null.
1919

20-
// Undefined
21-
// - You can assign literally a value as a `undefined`
22-
let undefined1 = undefined;
23-
// - Declared variable which doesn't assigned any value yet also has undefined as a value.
24-
let undefined2;
25-
26-
// Null
27-
// - Null is standalone value. To understand this let say you are creating weather application which give you the temperature of selected city. For any reason server unable to send you the temperature that means there is no temperature value. At that case weather app shouldn't show `0` on screen. Because 0 also refer as temperature value. At that time we use null to show there is actually no temperature and server are unable to fetch data of temperature.
28-
// - WHEN CHECK THE TYPEOF NULL IT WILL SHOW IT IS AN OBJECT.
29-
let myNull = null;
30-
3120
// Non-Primitive Data Types (Reference, Complex)
3221

3322
// Object

README.md

+30-28
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,19 @@
2828

2929
5. Datatype
3030

31-
1. Types Of Datatype
32-
2. Symbol
33-
3. NaN
31+
1. Primitive Data Type
32+
1. Number
33+
2. String
34+
3. Boolean
35+
4. Symbol
36+
2. Non-Primitive Data Type
37+
1. Object
38+
2. Array
39+
3. Function
40+
3. Stand Alone Values
41+
1. NaN
42+
2. Undefined
43+
3. Null
3444
4. Type Conversion
3545
5. Primitive & Non-Primitive Datatype
3646

@@ -160,32 +170,24 @@
160170

161171
# Monospace Font
162172

163-
1. MonoLisa
164-
2. Fira Mono
173+
1. Fira Mono Light
174+
2. JetBrains Mono ExtraLight
165175
3. Commit Mono
166-
4. Cascadia Code
167-
5. JetBrains Mono
176+
4. Fira Mono
177+
5. Monaspace
178+
6. MonoLisa
179+
7. Source Code Pro
180+
8. Cascadia Code
181+
9. JetBrains Mono
182+
10. Maple Mono
168183

169184
# Theme - Pitch Dark Background
170185

171-
1. Monokai Night
172-
2. Night Owl
173-
3. Noctis - Obscuro
174-
4. Ayu - Dark
175-
176-
177-
178-
179-
180-
181-
182-
183-
184-
185-
186-
187-
188-
189-
190-
191-
186+
1. Bluloco
187+
2. Dracula
188+
3. Github dark
189+
4. One Dark Mono
190+
5. Ayu - Dark
191+
6. Noctis - Obscuro
192+
7. Monokai Night
193+
8. Night Owl

0 commit comments

Comments
 (0)