Skip to content

Commit fd5e138

Browse files
committed
Initial Commit
1 parent 00bbf4a commit fd5e138

File tree

356 files changed

+10983
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

356 files changed

+10983
-0
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Introduction to JavaScript
2+
Welcome to the world of JavaScript! Today, having a solid understanding of JavaScript is crucial for anyone who wants to pursue a career in web development. With its versatility and wide-range of applications, JavaScript is one of the most important programming languages to learn. But don't worry, we'll start from the basics and gradually raise the bar. By the end of these tutorials, you'll be well on your way to becoming a JavaScript pro.
3+
4+
# What is Programming?
5+
Programming is the art of communicating with computers. Just like some of your friends might understand Hindi, others might understand English, computers understand programming. Think of it as a language that we use to tell computers what to do.
6+
7+
# The Dumb Computer
8+
Despite its incredible speed and accuracy, a computer is actually quite "dumb." It can only do exactly what you tell it to do, and nothing more. This means that you have to be very clear and precise in your instructions, or else the computer might do something unexpected. For example, if you asked a person to jump, they would probably know what you meant. But if you asked a computer to jump, it wouldn't have a clue!
9+
10+
This might sound like a hindrance, but it's actually one of the things that makes computers so useful. They can perform complex calculations and processes much faster than a person ever could. For example, if you asked a person to solve the equation 24 + 5, they might take a few seconds to give you the answer of 29. But a computer would solve that equation almost instantly.
11+
12+
# ECMAScript: The Standard Behind JavaScript
13+
ECMAScript is the standardized version of JavaScript that helps ensure that code written in JavaScript will work the same way on any computer. ECMAScript has come a long way since its inception, with new features and capabilities added with each new release. In most cases, "JavaScript" and "ECMAScript" can be used interchangeably.
14+
15+
One of the great things about JavaScript is that it's a very forgiving language. It tries to do something with the code you write, even if it's not exactly right, and will only throw an error if you've really messed up.
16+
17+
# How to Use JavaScript
18+
There are several ways to use JavaScript, including:
19+
20+
1. In the browser: Most modern browsers have a JavaScript console that you can use to test and run your code.
21+
22+
2. In HTML: You can add JavaScript to your HTML files and run it in the browser. This is a great way to add interactivity to your website.
23+
24+
3. With a runtime environment: One popular runtime environment for JavaScript is Node.js. Node.js was created when a programmer named Ryan Dahl took Google's V8 JavaScript engine and wrapped it in C++. This allows you to run JavaScript code outside of the browser, which is useful for server-side programming.
25+
26+
And, as a bonus, you can also use JavaScript in Replit, even if your computer's specs are low or you're on the go.
27+
28+
In conclusion, learning JavaScript will open up a world of possibilities for you. With its versatility and wide range of applications, there's no limit to what you can accomplish with this powerful programming language. So let's get started!
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"embedUrl":"https://www.youtube.com/embed/ER9SspLe4Hg"}

01IntroductiontoJs/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
console.log("Note: View Files from this Repl to Access the Source Code")
2+
console.log("This program adds 1, 2 and 54")
3+
4+
function addThreeNumbers(a, b, c) {
5+
return a + b + c;
6+
}
7+
let c = addThreeNumbers(1, 2, 54)
8+
console.log(c)

02Variables/.tutorial/01-variable.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<h1 align="center"> Foundation </h1>
2+
<h2 align="center"> Introduction to Syntax, Types of Languages, Comments and Variables </h2>
3+
4+
Before we dive into the world of programming, we need to understand the basics of syntax, types of languages, and variables. This chapter will cover the basics and lay a strong foundation for your programming journey.
5+
6+
# Syntax
7+
Just like there are some set of rules for writing a sentence in English, there are some set of rules for writing a program in a programming language. These rules are called syntax.
8+
Syntax is how a program is written and arranged. It defines the combination of symbols that are considered to be correctly structured.
9+
10+
# Types of Languages
11+
There are two main types of programming languages: dynamically typed and statically typed.
12+
13+
### Dynamically Typed
14+
Dynamically typed languages are the ones where the type of a variable is determined at runtime. This means that the type of a variable can change during the execution of the program. Js is example of a dynamically typed language.
15+
16+
### Statically Typed
17+
Statically typed languages are the ones where the type of a variable is determined at compile time. This means that the type of a variable cannot change during the execution of the program. C is example of a statically typed language.
18+
19+
# Comments
20+
Comments are used to explain the code. They are not executed by the computer. They are just for the programmer to understand the code. There are two types of comments: single line and multi-line.
21+
22+
### Single Line Comments
23+
Single line comments are used to comment a single line of code. They are denoted by `//`. Everything after `//` is a comment and will not be executed by the computer.
24+
25+
```js
26+
// This is a single line comment
27+
console.log("Hello World"); // This is also a single line comment
28+
```
29+
30+
### Multi-Line Comments
31+
Multi-line comments are used to comment multiple lines of code. They are denoted by `/*` and `*/`. Everything between `/*` and `*/` is a comment and will not be executed by the computer.
32+
33+
```js
34+
/*
35+
This is
36+
a multi-line
37+
comment.
38+
*/
39+
```
40+
Think of comments as sticky notes that you leave for yourself or others who may read your code in the future. They help make your code easier to understand and maintain.
41+
42+
# Variables
43+
Variables are used to store data. They are like containers that hold data.Just like there are different containers in your kitchen like one may be used to store rice, another may be used to store sugar, similarly, variables are used to store different types of data. And since javascript is a dynamically typed language, the type of data that can be stored in a variable can change during the execution of the program.
44+
45+
Variables are declared using the `var`, `let` or `const` keyword (we will discuss this in next lecture). The syntax for declaring a variable is as follows:
46+
47+
```js
48+
var name = "Harry";
49+
```
50+
51+
Here, `name` is the name of the variable and `"Harry"` is the value that is stored in the variable. The value can be of any type. It can be a string, a number, a boolean, an array, an object, etc. Don't worry if you don't understand what these terms mean. We will cover them in the upcoming lectures.
52+
53+
Now that we know what variables are, let's discuss some rules for naming variables.
54+
55+
## Rules for Naming Variables
56+
1. Variable names cannot start with a number.
57+
```js
58+
var 1name = "Harry"; // will throw an error because of the 1 at the start
59+
```
60+
2. Variable names cannot contain spaces.
61+
```js
62+
var my name = "Harry"; // will throw an error because of the space
63+
```
64+
3. Variable names cannot contain special characters like `!`, `@`, `#`, `$`, `%`, `^`, `&`, `*`, `(`, `)`, `-`, `+`, `=`, `[`, `]`, `{`, `}`, `|`, `\`, `:`, `;`, `<`, `>`, `,`, `.`, `/`, `?`, `~`.
65+
```js
66+
var my-name = "Harry"; // will throw an error because of the `-` character
67+
```
68+
4. Variable names cannot be a reserved keyword. Reserved keywords are the keywords that are already used by the language. For example, `var`, `let`, `const`, `if`, `else`, `for`, `while`, `function`, `return`, etc.
69+
```js
70+
var var = "Harry"; // will throw an error because var is a reserved keyword
71+
```
72+
5. Variable names are case sensitive. This means that `name` and `Name` are two different variables.
73+
```js
74+
var name = "Harry";
75+
var Name = "Ron";
76+
console.log(name); // will print "Harry"
77+
console.log(Name); // will print "Ron"
78+
```
79+
80+
[Go to next lecture](nextlectureslink)
81+
82+

02Variables/.tutorial/video.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"embedUrl":"https://www.youtube.com/embed/Q4p8vRQX8uY"}

02Variables/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
console.log("This repl contains code for the Ultimate JavaScript course video no 2")
2+
var a = 67 // a contains 67
3+
console.log(a)
4+
a = "harry"
5+
console.log(a)
6+
// let 8harry = 7 // Not allowed this will throw an error
7+
// let var = 7

03varletconst/.tutorial/01-var.md

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<h1 align="center"> Variables </h1>
2+
<h2 align="center"> var, let and const </h2>
3+
4+
In the previous video, we learned about syntax, types of languages, comments and variables. In this chapter, we will learn about the `var`, `let` and `const` keywords and how to declare variables using them.
5+
6+
# var, let and const
7+
In javascript, there are three keywords that are used to declare variables: `var`, `let` and `const`. The `var` keyword was used to declare variables in javascript before the `let` and `const` keywords were introduced. The `let` and `const` keywords were introduced in ES6 (ECMAScript 6). ES6 is the latest version of javascript. It was released in 2015. ES6 introduced a lot of new features to javascript. We will learn about some of them in this course.
8+
9+
# var
10+
The `var` keyword is used to declare variables in JavaScript. Here's an example:
11+
```js
12+
var name = "Harry";
13+
console.log(name); //output: Harry
14+
```
15+
we can also reassign the value of a variable declared using the `var` keyword:
16+
```js
17+
var name = "Harry";
18+
name = "Ron";
19+
console.log(name); //output: Ron
20+
```
21+
One important thing to note about var is that it has block scope. This means that if a variable is declared with var inside a function, it is accessible anywhere within that block.
22+
23+
Note: Block scope will be discussed in the upcoming videos. For now, just remember that anything inside curly braces `{}` is a block.
24+
25+
Here's an example:
26+
```js
27+
var name = "Harry";
28+
{
29+
var name = "Ron";
30+
console.log(name); //output: Ron
31+
}
32+
console.log(name); //output: Ron
33+
```
34+
This is the reason why the `var` keyword is not recommended to be used anymore. It can lead to unexpected results. Instead we make use of the `let` and `const` keywords.
35+
36+
# let
37+
The let keyword is used to declare variables in JavaScript and has block scope. This means that if a variable is declared with let inside a block, it is only accessible within that block.
38+
39+
Here's an example:
40+
```js
41+
let a = 29
42+
43+
let b = " Harry";
44+
{
45+
let b = "this";
46+
console.log(b); //output: this
47+
}
48+
console.log(b); //output: Harry
49+
```
50+
51+
# const
52+
The `const` keyword is used to declare variables in JavaScript and is used when you don't want to reassign the variable. The value of a variable declared with `const` cannot be changed.
53+
54+
Here's an example:
55+
```js
56+
const name = " Harry";
57+
name = "this";
58+
console.log(name); //output: Uncaught TypeError: Assignment to constant variable.
59+
```
60+
61+
# Differences
62+
63+
| | **Block scoped** | **Hoisting** | **Reassignment** | **Initialization** |
64+
|----------|-------------------|--------------|------------------|--------------------|
65+
| `let` | Yes | No | Yes | Optional |
66+
| `var` | No | Yes | Yes | Optional |
67+
| `const` | Yes | No | No | Required |
68+
69+
70+
* **Block scoped**: `let` and `const` are block-scoped, meaning they are only accessible within the block they were defined in, while `var` is function-scoped, meaning it is accessible within the entire function it was defined in.
71+
* **Hoisting:** `let` and `const` are not hoisted, meaning they cannot be accessed before they are declared, while `var` is hoisted, meaning it can be accessed before it is declared (although it will have a value of undefined).
72+
* **Reassignment:** `let` and `var` can be reassigned to a new value, while `const` cannot be reassigned.
73+
* **Initialization:** `let` and `var` can be declared without being initialized, while `const` must be initialized with a value when it is declared.
74+
75+
76+
# Best Practices
77+
Now we know everything about the variables in JavaScript. Let's look at some best practices that we should follow while declaring variables in JavaScript to make our code more readable and maintainable.
78+
79+
1. Use descriptive and meaningful variable names: Choose variable names that clearly describe the value they hold. This makes your code easier to read and understand.
80+
```js
81+
const a = "Harry"; //bad
82+
const name = "Harry"; //good
83+
```
84+
2. Use camelCase to name your variables. This makes your code easier to read and understand.
85+
```js
86+
const myName = "Harry"; //good
87+
const myname = "Harry"; //bad
88+
```
89+
3. Use const by default and only use let if you need to reassign the variable. Avoid using var.
90+
```js
91+
const name = "Harry"; //good
92+
let temporary = 29; //good
93+
var name = "Harry"; //bad
94+
```
95+
4. Declare variables at the top of their scope: To make your code more readable, it's best to declare variables at the top of their scope. This makes it easier to see what variables are in scope and what values they hold
96+
```js
97+
//good:
98+
{
99+
const name = "Harry";
100+
const hobby = "programming";
101+
102+
console.log("My name is " + name + " and I love " + hobby); // output: My name is Harry and I love programming
103+
}
104+
//bad
105+
{
106+
console.log("My name is " + name + " and I love " + hobby); // output: My name is undefined and I love undefined
107+
const name = "Harry";
108+
const hobby = "programming";
109+
}
110+
```
111+
5. Use const whenever possible: If you know that a variable will not change, use const to declare it. This helps to prevent bugs in your code that could occur if you accidentally reassign a value to a variable that should not change.
112+
```js
113+
const name = "Harry"; //good
114+
let name = "Harry"; //fine but const is better because we know that the value of name will not change
115+
var name = "Harry"; //bad
116+
```
117+
118+
# Conclusion
119+
Variables are an essential part of JavaScript programming. They allow us to store and manipulate data in our code. In JavaScript, we can declare variables using the `var`, `let`, and `const` keywords. While the `var` keyword has block scope, it can lead to unexpected results and is no longer recommended. Instead, we should use the `let` and `const` keywords, with `const` being the preferred option whenever possible. When declaring variables, we should follow best practices like using descriptive names, using camelCase, declaring variables at the top of their scope, and using `const` by default. By following these practices, we can make our code more readable and maintainable.
120+
121+
[Go to next lecture](nextlectureslink)

03varletconst/.tutorial/video.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"embedUrl":"https://www.youtube.com/embed/Icev9Oxf0WA"}

03varletconst/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
console.log("JavaScript tutorial 3: var, let and const")
2+
// var a = 45;
3+
// var a = "p"
4+
let b = "Harry";
5+
const author = "Harry"
6+
author = 5 // Throws an error because constant cannot be changed
7+
b = 4
8+
const harry = 0;
9+
let c = null
10+
let d = undefined
11+
{
12+
let b = 'this'
13+
console.log(b)
14+
}
15+
console.log(b)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Primitives and Objects
2+
In JavaScript, there are 7 primitive data types. The primitive data types are fundamental data types that are built into JavaScript. A good trick to remember these 7 data types is `"NNSSBBU"`:
3+
- N - null
4+
- N - number
5+
- S - symbol
6+
- S - string
7+
- B - boolean
8+
- B - bigint
9+
- U - undefined
10+
11+
These data types are used to define the type of variables and the type of content that can be stored in them. For example:
12+
13+
```js
14+
let nullVar = null;
15+
let numVar = 29;
16+
let boolVar = true;
17+
let bigIntVar = BigInt("567");
18+
let strVar = "harry";
19+
let symbolVar = Symbol("I'm a nice symbol");
20+
let undefinedVar = undefined;
21+
```
22+
It's important to use descriptive variable names instead of generic ones like a, b, c, etc.
23+
24+
## null vs undefined
25+
The null data type represents the intentional absence of any object value, whereas the undefined data type indicates the absence of a defined value. For example:
26+
27+
```js
28+
let nullVar = null; // value is intentionally nothing
29+
let undefinedVar; // value is undefined or not defined
30+
```
31+
## Using `typeof`
32+
We can use the `typeof` operator to determine the data type of a variable. For example:
33+
34+
```js
35+
console.log(typeof numVar); // Output: number
36+
console.log(typeof strVar); // Output: string
37+
```
38+
# Objects
39+
Other than the 7 primitive data types, the non-primitive data type in JavaScript is the object. Objects are key-value pairs, used to map keys to values. We can create an object like this:
40+
41+
```js
42+
const bioData = {
43+
name: "Harry",
44+
age: 29,
45+
likesJS: true,
46+
secret: undefined,
47+
};
48+
```
49+
We can access an object's values in two ways: by using square brackets [] or by using dot notation . For example:
50+
51+
```js
52+
console.log(bioData["name"]); // Output: Harry
53+
console.log(bioData.age); // Output: 29
54+
console.log(bioData["pet"]); // Output: undefined
55+
```
56+
**Note:** see how ["pet"] says undefined, this is because the key "pet" doesn't exist in the object bioData.
57+
58+
# Conclusion
59+
Remember that variables are like containers, and data types define what type of content can be stored in them. Just like we wouldn't store our cookies in a container meant for pesticides, it's important to use the correct data types in JavaScript.
60+
61+
Another key point to remember is that objects are used to map keys to values and can be accessed using square brackets [] or dot notation .
62+
63+
```js
64+
const harryMarks = {
65+
english: 100,
66+
maths: 80,
67+
chemistry: 40,
68+
};
69+
70+
const shubhMarks = {
71+
english: 70,
72+
maths: 100,
73+
chemistry: 60,
74+
};
75+
```
76+
In conclusion, understanding primitive data types and objects is important for writing effective JavaScript code. By using the correct data types, we can improve the efficiency and readability of our code.
77+
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"embedUrl":"https://www.youtube.com/embed/qpU3WIqRz9I"}

04primitivesobjects/index.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// nn bb ss u - Primitives in Js
2+
let a = null;
3+
let b = 345;
4+
let c = true; // can also be false
5+
let d = BigInt("567") + BigInt("3")
6+
let e = "Harry"
7+
let f = Symbol("I am a nice symbol")
8+
let g
9+
console.log(a, b, c , d, e, f, g)
10+
console.log(typeof c)
11+
12+
// Non Primitive Data Type - Objects in Js
13+
const item = {
14+
"Harry": true,
15+
"Shubh": false,
16+
"Lovish": 67,
17+
"Rohan": undefined
18+
}
19+
console.log(item["Shubh"])

0 commit comments

Comments
 (0)