Skip to content

Commit

Permalink
Merge pull request #4322 from CodeHarborHub/restyled/dev-3
Browse files Browse the repository at this point in the history
Restyle Dev 3
  • Loading branch information
ajay-dhangar authored Aug 19, 2024
2 parents 2f257a3 + f3b7efa commit 4e599aa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
14 changes: 7 additions & 7 deletions docs/CSS/_category_.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"label": "CSS",
"position": 20,
"link": {
"type": "generated-index",
"description": "In this section, you will learn about the CSS."
}
}
"label": "CSS",
"position": 20,
"link": {
"type": "generated-index",
"description": "In this section, you will learn about the CSS."
}
}
5 changes: 3 additions & 2 deletions docs/javascript/all-about-variables/hoisting.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Function expressions are not hoisted in the same way as function declarations. O
```javascript title="app.js"
sayHello(); // Throws a TypeError

var sayHello = function() {
var sayHello = function () {
console.log("Hello, World!");
};
```
Expand All @@ -118,6 +118,7 @@ By understanding how hoisting works, you can avoid common pitfalls and write mor
To avoid confusion and potential issues related to hoisting, it's a good practice to declare your variables and functions at the beginning of their containing scope. This makes your code more readable and predictable.

**Remember:**

- Use `let` and `const` for variable declarations to avoid hoisting-related bugs.
- Declare functions before calling them to ensure they are hoisted correctly.
- Be mindful of the TDZ when using `let` and `const` to prevent `ReferenceError` issues.
Expand All @@ -129,4 +130,4 @@ Hoisting can feel like magic, but understanding how it works will help you write

## Conclusion

Hoisting is a unique feature of JavaScript that allows you to access variables and functions before they are declared in your code. By hoisting declarations to the top of their containing scope, JavaScript enables you to write code that might seem out of order but still works as expected.
Hoisting is a unique feature of JavaScript that allows you to access variables and functions before they are declared in your code. By hoisting declarations to the top of their containing scope, JavaScript enables you to write code that might seem out of order but still works as expected.
15 changes: 9 additions & 6 deletions docs/javascript/all-about-variables/variable-naming-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: Learn about the rules and best practices for naming variables in Ja

<AdsComponent />

When writing JavaScript code, it's essential to follow consistent naming conventions for variables to improve code readability and maintainability. Variable names should be descriptive, meaningful, and follow certain rules to ensure clarity and avoid conflicts.
When writing JavaScript code, it's essential to follow consistent naming conventions for variables to improve code readability and maintainability. Variable names should be descriptive, meaningful, and follow certain rules to ensure clarity and avoid conflicts.

In this tutorial, we'll cover the essential rules for naming variables in JavaScript, along with examples and tips to help you avoid common mistakes.

Expand Down Expand Up @@ -44,11 +44,12 @@ By following the rules and best practices for naming variables, you can write be

When naming variables in JavaScript, you need to follow certain rules and conventions to ensure consistency and readability. Here are the essential rules for naming variables:

### 1. Variable Names Must Begin with a Letter, Underscore (_), or Dollar Sign ($)
### 1. Variable Names Must Begin with a Letter, Underscore (\_), or Dollar Sign ($)

A variable name can start with any of these three characters:

- **Letter**: The first character of a variable name must be a letter (a-z, A-Z) or an uppercase or lowercase letter.
- Underscore (_): You can use an underscore as the first character of a variable name. It is commonly used to indicate a private or internal variable.
- Underscore (\_): You can use an underscore as the first character of a variable name. It is commonly used to indicate a private or internal variable.
- Dollar Sign ($): While the dollar sign can be used in variable names, it is less common and not recommended due to its use in certain JavaScript libraries and frameworks.

**Example:**
Expand All @@ -58,12 +59,14 @@ let name = "Alice";
let _count = 10;
let $price = 25.99;
```

### 2. Variable Names Can Contain Letters, Numbers, Underscores, and Dollar Signs

After the first character, variable names can include:

- Letters (a-z, A-Z)
- Numbers (0-9)
- Underscores (_)
- Underscores (\_)
- Dollar Signs ($)

**Examples:**
Expand Down Expand Up @@ -130,7 +133,7 @@ let coordinateX = 10;

// Acceptable in loops
for (let i = 0; i < 10; i++) {
console.log(i);
console.log(i);
}
```

Expand Down Expand Up @@ -216,4 +219,4 @@ By following these guidelines, you can create well-structured, readable, and mai

## Conclusion

In this tutorial, you learned about the rules and best practices for naming variables in JavaScript. By following these guidelines, you can write clean, consistent, and readable code that is easier to maintain and understand. Remember that choosing meaningful and descriptive variable names is essential for improving code quality, readability, and maintainability.
In this tutorial, you learned about the rules and best practices for naming variables in JavaScript. By following these guidelines, you can write clean, consistent, and readable code that is easier to maintain and understand. Remember that choosing meaningful and descriptive variable names is essential for improving code quality, readability, and maintainability.

0 comments on commit 4e599aa

Please sign in to comment.