Skip to content

Commit

Permalink
added new content
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-dhangar committed Feb 24, 2024
1 parent 27339a3 commit b1ec704
Show file tree
Hide file tree
Showing 43 changed files with 291 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ COPY package*.json ./
COPY . .

# Install node packages, install serve, build the app, and remove dependencies at the end
RUN npm install \
&& npm install serve \
&& npm run build
RUN npm install && npm run build

# Expose the port 3000
EXPOSE 3000

# Start the app using serve command
CMD [ "serve", "build" ]
ENTRYPOINT npm run start
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ This project is licensed under the [MIT License](#).

## Workflows

[![Deploy to GitHub Pages](https://github.com/Ajay-Dhangar/code-harbor-hub/actions/workflows/deploy.yml/badge.svg)](https://github.com/Ajay-Dhangar/code-harbor-hub/actions/workflows/deploy.yml)
[![Deploy to GitHub Pages](https://github.com/Ajay-Dhangar/code-harbor-hub/actions/workflows/deploy.yml/badge.svg)](https://github.com/Ajay-Dhangar/code-harbor-hub/actions/workflows/deploy.yml) [![Hadolint](https://github.com/Ajay-Dhangar/code-harbor-hub/actions/workflows/hadolint.yml/badge.svg)](https://github.com/Ajay-Dhangar/code-harbor-hub/actions/workflows/hadolint.yml) [![Docker Image CI](https://github.com/Ajay-Dhangar/code-harbor-hub/actions/workflows/docker-image.yml/badge.svg)](https://github.com/Ajay-Dhangar/code-harbor-hub/actions/workflows/docker-image.yml) [![CodeQL](https://github.com/Ajay-Dhangar/code-harbor-hub/actions/workflows/codeql.yml/badge.svg)](https://github.com/Ajay-Dhangar/code-harbor-hub/actions/workflows/codeql.yml)
8 changes: 8 additions & 0 deletions docs/javascript/const-js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: const-in-javascript
title: Const Keyword in JavaScript
sidebar_label: Const Keyword
sidebar_position: 9
tags: [JavaScript]
description: What is the const keyword in JavaScript and how to use it.
---
8 changes: 8 additions & 0 deletions docs/javascript/datatypes/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Data Types in JavaScript",
"position": 11,
"link": {
"type": "generated-index",
"description": "Learn the most popular programming language in the world."
}
}
8 changes: 8 additions & 0 deletions docs/javascript/datatypes/datatypes-js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: datatypes-in-javascript
title: Data Types in JavaScript
sidebar_label: Data Types
sidebar_position: 1
tags: [JavaScript]
description: What is the data types in JavaScript and how to use it.
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Non Primitive Data Types",
"position": 3,
"link": {
"type": "generated-index",
"description": "Learn the most popular programming language in the world."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: object-datatypes-in-javascript
title: Object Data Types in JavaScript
sidebar_label: Object
sidebar_position: 1
tags: [JavaScript]
description: What is the data types in JavaScript and how to use it.
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Primitive Data Types",
"position": 2,
"link": {
"type": "generated-index",
"description": "Learn the most popular programming language in the world."
}
}
8 changes: 8 additions & 0 deletions docs/javascript/datatypes/primitive-data-types/number-js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: number-datatypes-in-javascript
title: Number Data Types in JavaScript
sidebar_label: Number
sidebar_position: 1
tags: [JavaScript]
description: What is the data types in JavaScript and how to use it.
---
Empty file added docs/javascript/events-js.md
Empty file.
13 changes: 13 additions & 0 deletions docs/javascript/let-js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
id: let-in-javascript
title: Let Keyword in JavaScript
sidebar_label: Let Keyword
sidebar_position: 8
tags: [JavaScript]
description: What is the let keyword in JavaScript and how to use it.
---

In JavaScript, the `let` keyword is used to declare a block-scoped variable. It was introduced in <mark>ECMAScript 6 (ES6)</mark> and is the preferred way to declare variables in modern JavaScript.

> ***ES6 (ECMAScript 2015) is a major update to JavaScript that adds new syntax and features to the language. It was officially released in June 2015.***
8 changes: 8 additions & 0 deletions docs/javascript/operators/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Operators in JavaScript",
"position": 10,
"link": {
"type": "generated-index",
"description": "Learn the most popular programming language in the world."
}
}
8 changes: 8 additions & 0 deletions docs/javascript/operators/arithmetic-js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: arithmetic-operator-in-javascript
title: Arithmetic Operator in JavaScript
sidebar_label: Arithmetic Operator
sidebar_position: 2
tags: [JavaScript]
description: What is the arithmetic operator in JavaScript and how to use it.
---
Empty file.
8 changes: 8 additions & 0 deletions docs/javascript/operators/operators-js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: operators-in-javascript
title: Operators in JavaScript
sidebar_label: Operators
sidebar_position: 1
tags: [JavaScript]
description: What is the operators in JavaScript and how to use it.
---
129 changes: 128 additions & 1 deletion docs/javascript/variables-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: variables-in-javascript
title: Variables in JavaScript
sidebar_label: Variables in JavaScript
sidebar_position: 7
tags: [JavaScript, Variables, variables in js, JavaScript variables]
tags: [JavaScript, Variables, variables in js, JavaScript variables, let, const, var, variable naming rules, variable best practices, variable declaration, variable initialization, variable scope, variable hoisting, variable re-declaration, variable re-assignment, variable mutable, variable naming conventions, variable naming best practices, variable naming rules, variable naming guidelines, variable naming standards, variable naming conventions in JavaScript, variable naming best practices in JavaScript, variable naming rules in JavaScript, variable naming guidelines in JavaScript, variable naming standards in JavaScript, variable naming conventions in JS, variable naming best practices in JS, variable naming rules in JS, variable naming guidelines in JS, variable naming standards in JS, variable naming conventions in JavaScript, variable naming best practices in JavaScript, variable naming rules in JavaScript, variable naming guidelines in JavaScript, variable naming standards in JavaScript, variable naming conventions in JS, variable naming best practices in JS, variable naming rules in JS, variable naming guidelines in JS, variable naming standards in JS, variable naming conventions in JavaScript, variable naming best practices in JavaScript, variable naming rules in JavaScript, variable naming guidelines in JavaScript, variable naming standards in JavaScript, variable naming conventions in JS, variable naming best practices in JS, variable naming rules in JS, variable naming guidelines in JS, variable naming standards in JS, variable naming conventions in JavaScript, variable naming best practices in JavaScript, variable naming rules in JavaScript, variable naming guidelines in JavaScript, variable naming standards in JavaScript, variable naming conventions in JS, variable naming best practices in JS, variable naming rules in JS, variable naming guidelines in JS, variable naming standards in JS, variable naming conventions in JavaScript, variable naming best practices in JavaScript, variable naming rules in JavaScript, variable naming guidelines in JavaScript, variable naming standards in JavaScript, variable naming conventions in JS, variable naming best practices in JS, variable naming rules in JS, variable naming guidelines in JS, variable naming standards in JS, variable naming conventions in JavaScript, variable naming best practices in JavaScript, variable naming rules in JavaScript, variable naming guidelines in JavaScript, variable naming standards in JavaScript, variable naming conventions in JS, variable naming best practices in JS, variable naming rules in JS, variable naming guidelines in JS, variable naming standards in JS, variable naming conventions in JavaScript, variable naming best practices in JavaScript, variable naming rules in JavaScript, variable naming guidelines in JavaScript, variable naming standards in JavaScript, variable naming conventions in JS, variable naming best practices in JS, variable naming rules in JS, variable naming guidelines in JS, variable naming standards in JS, variable naming conventions in JavaScript, variable]
description: What are variables in JavaScript? How to declare and initialize variables in JavaScript? Learn about variable naming rules and best practices.
---

Expand Down Expand Up @@ -171,6 +171,133 @@ When naming variables in JavaScript, you should follow these best practices:
6. Do not use a too long or too short variable name.
for example, `thisIsAVeryLongVariableName`, `a`, `b`, etc.

## Differents between var, let, and const in JavaScript

In JavaScript, you can declare a variable using the `var`, `let`, or `const` keyword. Each keyword has different behavior and scope.

| Keyword | Scope | Hoisting |TDZ | Re-declaration | Re-assignment | Mutable |
|:-------:|:-----:|:--------:|:--:|:--------------:|:-------------:|:-------:|
| var | Function | Yes | No | Yes | Yes | Yes |
| let | Block | No | Yes | No | Yes | Yes |
| const | Block | No | Yes | No | No | No |

- **Scope**: The scope of a variable is the region of the program where the variable is accessible. The scope of a variable can be global or local. The `var` keyword has a function scope, while the `let` and `const` keywords have a block scope.

for example,

```js title="scope.js"
var x = 10;
let y = 20;
const z = 30;

function test() {
var a = 40;
let b = 50;
const c = 60;
console.log(a, b, c); // 40 50 60
}

console.log(x, y, z); // 10 20 30
console.log(a, b, c); // ReferenceError: a is not defined
```

- **Hoisting**: Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their containing scope during the compilation phase. The `var` keyword is hoisted, while the `let` and `const` keywords are not hoisted.

for example,

```js title="hoisting.js"
console.log(x); // undefined
var x = 10;
```

- **Temporal Dead Zone (TDZ)**: The temporal dead zone is a behavior in JavaScript where you cannot access a variable before it is declared. The `let` and `const` keywords have a temporal dead zone, while the `var` keyword does not have a temporal dead zone.

for example,

```js title="tdz.js"
console.log(x); // ReferenceError: Cannot access 'x' before initialization
let x = 10;
```

- **Re-declaration**: The `var` keyword allows you to re-declare a variable in the same scope, while the `let` and `const` keywords do not allow you to re-declare a variable in the same scope.

for example,

```js title="re-declaration.js"
var x = 10;
var x = 20;
console.log(x); // 20

let y = 30;
let y = 40; // SyntaxError: Identifier 'y' has already been declared
```

- **Re-assignment**: The `var`, `let`, and `const` keywords allow you to re-assign a value to a variable. However, the `const` keyword does not allow you to re-assign a value to a variable.

for example,

```js title="re-assignment.js"
var x = 10;
x = 20;
console.log(x); // 20

let y = 30;
y = 40;
console.log(y); // 40

const z = 50;
z = 60; // TypeError: Assignment to constant variable.
```

- **Mutable**: The `var` and `let` keywords allow you to mutate the value of a variable, while the `const` keyword does not allow you to mutate the value of a variable.

for example,

```js title="mutable.js"
var x = 10;
x = 20;
console.log(x); // 20

let y = 30;
y = 40;
console.log(y); // 40

const z = 50;
z = 60; // TypeError: Assignment to constant variable.
```

```mermaid
graph TD;
A[Variables] --> B{Scope};
B --> |var| C[Function];
B --> |let| D[Block];
B --> |const| E[Block];
A --> F{Hoisting};
F --> |var| G[Yes];
F --> |let| H[No];
F --> |const| I[No];
A --> J{Temporal Dead Zone};
J --> |var| K[No];
J --> |let| L[Yes];
J --> |const| M[Yes];
A --> N{Re-declaration};
N --> |var| O[Yes];
N --> |let| P[No];
N --> |const| Q[No];
A --> R{Re-assignment};
R --> |var| S[Yes];
R --> |let| T[Yes];
R --> |const| U[No];
A --> V{Mutable};
V --> |var| W[Yes];
V --> |let| X[Yes];
V --> |const| Y[No];
```

:::important
It is recommended to use `let` and `const` instead of `var` to declare variables. Use `let` when you want to declare a variable that can be re-assigned, and use `const` when you want to declare a variable that cannot be re-assigned.
:::

## Conclusion

In this tutorial, you learned about variables in JavaScript. You learned what variables are, how to declare and initialize variables, and the rules and best practices for naming variables. In the next tutorial, you will learn about data types in JavaScript.
8 changes: 8 additions & 0 deletions web-dev/javascript/advanced-topics/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Advanced Topics",
"position": 10,
"link": {
"type": "generated-index",
"description": "5 minutes to learn the most important RoadMap for JavaScript Mastery."
}
}
Empty file.
Empty file.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions web-dev/javascript/arrays-and-objects/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Arrays and Objects",
"position": 5,
"link": {
"type": "generated-index",
"description": "5 minutes to learn the most important RoadMap for JavaScript Mastery."
}
}
8 changes: 8 additions & 0 deletions web-dev/javascript/asynchronous-javascript/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Asynchronous JavaScript",
"position": 7,
"link": {
"type": "generated-index",
"description": "5 minutes to learn the most important RoadMap for JavaScript Mastery."
}
}
Empty file.
Empty file.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions web-dev/javascript/control-flow-and-functions/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Control Flow and Functions",
"position": 4,
"link": {
"type": "generated-index",
"description": "5 minutes to learn the most important RoadMap for JavaScript Mastery."
}
}
8 changes: 8 additions & 0 deletions web-dev/javascript/dom-manipulation/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "DOM Manipulation",
"position": 6,
"link": {
"type": "generated-index",
"description": "5 minutes to learn the most important RoadMap for JavaScript Mastery."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Error Handling and Debugging",
"position": 8,
"link": {
"type": "generated-index",
"description": "5 minutes to learn the most important RoadMap for JavaScript Mastery."
}
}
Empty file.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions web-dev/javascript/modern-javascript-concepts/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Modern JavaScript Concepts",
"position": 9,
"link": {
"type": "generated-index",
"description": "5 minutes to learn the most important RoadMap for JavaScript Mastery."
}
}
Empty file.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions web-dev/javascript/tools-and-resources/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Tools and Resources",
"position": 11,
"link": {
"type": "generated-index",
"description": "5 minutes to learn the most important RoadMap for JavaScript Mastery."
}
}
Empty file.
Empty file.
Empty file.
Empty file.
5 changes: 3 additions & 2 deletions web-dev/javascript/welcome-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ JavaScript is a versatile language and is used for more than just web pages. For
- Performance optimization techniques
- Security best practices in JavaScript development
- **Tools and Resources**
- Useful JavaScript libraries and frameworks
- Recommended books and online resources
- Useful JavaScript libraries and frameworks
- Recommended books and online resources
- Popular development tools and IDEs for JavaScript development
- Community forums and online communities for JavaScript developers


0 comments on commit b1ec704

Please sign in to comment.