Skip to content

Commit 6847395

Browse files
Control Flow of JavaScript ✅
1 parent bbcebc4 commit 6847395

File tree

33 files changed

+2394
-0
lines changed

33 files changed

+2394
-0
lines changed

1. Intro to JavaScript/1.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// EcmaScript 2022 (JavaScript)
2+
3+
// History of JavaScript
4+
/*
5+
In 1995 There was a Browser Name Netscpae Navigator
6+
They Thought That Should have a Programming Language Navigator
7+
Which They can Interact With There Browser
8+
9+
Brendan Eich Was Working in Netscape Navigator
10+
So Brendan Eich Created JavaScript in 10 Days In 1995
11+
12+
13+
1st JavaScript Name was Mocha
14+
2nd JavaScript Name was LiveScript
15+
16+
LiveScript Was Not Getting Popular
17+
18+
So at that Time JAVA was Popular and More Demanding
19+
20+
So They Changed LiveScript to JavaScript
21+
22+
Java and JavaScript both are Differnet Programming Languages
23+
24+
In 1996 Internet Explorer
25+
They Too Created a New Programming Languages Name as JScript
26+
27+
People got confused w hich langauge to use JavaScript OR JScript
28+
29+
So They Both Went to ECMA European Computer Manufactors Association
30+
31+
ECMA is a Standard Organization Where They Decide what to show on Browser and Behave on Internet and Differnet other Technologies
32+
33+
ECMA Script and JavaScript are Same
34+
35+
Now ECMA is Standarisd So now its Called ECMA Script
36+
37+
ECMA Script ES1 : 1997
38+
ES5 : 2009
39+
ES6 : 2015 (Biggest Update of JS in History)
40+
ES7 : 2016
41+
ES8 : 2017
42+
43+
44+
TC 39 ... Technical Community 39
45+
They Decide What new features Should be Added In ECMA Script
46+
47+
48+
JavaScript is Backward Compatible
49+
50+
JavaScript Code Written can work Upto Ages
51+
52+
JavaScript is not Forward Compatible
53+
54+
EcmaScript is a Popular Programming Language where it has
55+
wide range of applications and it is light weighted
56+
57+
It can be used both client side and server side
58+
59+
Previously it was used to create a interative forms and animations
60+
But Nowadays it is used to create Apps and Server Side Development
61+
62+
Because it has wide range of applications. It can be used in serveral ways
63+
64+
1.Console in Browser Tabs
65+
2.Using Node JS
66+
3.By Creating Web Pages
67+
68+
*/
69+
70+
71+

2. Basic of JavaScript/1-12/1.js

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
// To Display The Output We Use Console.log
2+
console.log("Hello World");
3+
console.log('Hello World');
4+
// ----------------------------------------------------
5+
// //Double Quotations and Single Quotations are Same both can be Used
6+
// ----------------------------------------------------
7+
// //Comments in JavaScript
8+
9+
// // Single Line Comment Starts with //
10+
11+
// // This is a Single Line Comment
12+
13+
/*
14+
This is a Multi Line Comment
15+
This is a Multi Line Comment
16+
This is a Multi Line Comment
17+
This is a Multi Line Comment
18+
*/
19+
// -
20+
21+
22+
// To Run This File
23+
// node fileName.js
24+
// node 1.js
25+
26+
27+
28+
29+
// / Differnet Uses of Console logs
30+
31+
// let x = 1;
32+
// console.log(x); // 1
33+
34+
// let y = 2,z=3,q=5;
35+
// console.log(y,z,q);//2 3 5
36+
37+
// How to Convert an Output in an Object just to show it
38+
// It will not change its data type
39+
// Just Add {} in Console
40+
// let x = 1
41+
// let y = 2
42+
// let z = 3
43+
// console.log( {x, y, z} )
44+
45+
// %s is for string
46+
// %d is for number
47+
// console.log("%s is %d years old.", "John", 29)
48+
49+
// Variations of logs
50+
// There are a few variations of logs. There is the most widely used console.log(). But there is also:
51+
52+
// console.log("Console Log");
53+
// console.info("Console Info");
54+
// console.debug("Console Debug");
55+
// console.warn("Console Warn");
56+
// console.error("Console Error");
57+
// console.count();
58+
59+
// for(i=0; i<10; i++){
60+
// console.count();
61+
//
62+
// }
63+
64+
// console.time();
65+
// setTimeout(() => {
66+
// console.log("This Message Printed After 5 Seconds");
67+
// console.timeEnd();
68+
// }, 5000);
69+
70+
// Output:
71+
// This Message Printed After 5 Seconds
72+
// default: 5.007s
73+
74+
// console.time()
75+
76+
// setTimeout(() => {
77+
// console.timeEnd()
78+
// }, 5000)
79+
80+
// setTimeout(() => {
81+
// console.timeLog()
82+
// }, 2000)
83+
84+
// ----------------------------------------
85+
// console.log('I am not in a group')
86+
87+
// console.group()
88+
// console.log('I am in a group')
89+
// console.log('I am also in a group')
90+
// console.groupEnd()
91+
92+
// console.log('I am not in a group')
93+
94+
// Output:
95+
// I am not in a group
96+
// I am in a group
97+
// I am also in a group
98+
// I am not in a
99+
100+
// -----------------------------------
101+
102+
103+
// let devices = [
104+
// {
105+
// name: 'iPhone',
106+
// brand: 'Apple'
107+
// },
108+
// {
109+
// name: 'Galaxy',
110+
// brand: 'Samsung'
111+
// }
112+
// ]
113+
114+
// console.table(devices)
115+
116+
// ┌─────────┬──────────┬───────────┐
117+
// │ (index) │ name │ brand │
118+
// ├─────────┼──────────┼───────────┤
119+
// │ 0 │ 'iPhone' │ 'Apple' │
120+
// │ 1 │ 'Galaxy' │ 'Samsung' │
121+
// └─────────┴──────────┴───────────┘
122+
123+
// %c is for Styling // Visble in Browser Console
124+
// console.log("%c This is yellow text on a blue background.", "color:yellow; background-color:blue")
125+
126+
127+
128+
// --------------------------------------------------------
129+
// Just add console.clear() to the top of your code and you'll have a fresh console every time you refresh. ?
130+
// Just don't add it to the bottom of your code, lol.
131+
// console.clear()
132+
133+
// console.assert
134+
// This method is used to check if a condition is true. If it's not, it will throw an error.
135+
136+
// console.assert(/** Condition **/, /** Error message **/);
137+
138+
139+
// console.assert(1 === 1, "1 is equal to 1"); // No error
140+
// console.assert(0 === [], "0 is equal to []"); // Error in the console
141+
142+
143+
const {log:say} = console;
144+
145+
say("Hey Suhail");
146+
147+
var bol = console.log
148+
bol("hello")

2. Basic of JavaScript/1-12/10.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Reassign the VAR in VARIABLE_NAME to a new value. ✅
2+
var a = "apple";
3+
a = "ball";
4+
console.log(a); // ball // No Error ✅
5+
6+
var a = "apple";
7+
var a = "applesss";
8+
console.log(a); // applesss // No Error ✅
9+
// ------------------------------------------------------------------
10+
// Reassign the LET in VARIABLE_
11+
let b = "boat";
12+
b = "banana";
13+
console.log(b); // banana // No Error ✅
14+
15+
// let b = "boat";
16+
// let b = "banana";
17+
// console.log(b); // banana // Error - Cannot redeclare b ❌
18+
19+
//------------------------------------------------------------------
20+
21+
// const c = 3.14;
22+
// c = 45;
23+
// console.log(c); // 3.14 // Error - Cannot re-assign c ❌
24+
25+
// const c = 3.1457;
26+
// const c = 65;
27+
// console.log(c); // 3.1457 // Error - Cannot re-assign c ❌

0 commit comments

Comments
 (0)