Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6aad861

Browse files
Added topics Arrays,functions,objects,IIFE,closures,DOM
0 parents  commit6aad861

File tree

61 files changed

+2815
-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.

61 files changed

+2815
-0
lines changed

‎.vscode/launch.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version":"0.2.0",
6+
"configurations": [
7+
{
8+
"name":"Attach to Chrome",
9+
"port":9222,
10+
"request":"attach",
11+
"type":"pwa-chrome",
12+
"webRoot":"${workspaceFolder}"
13+
},
14+
{
15+
"type":"pwa-chrome",
16+
"request":"launch",
17+
"name":"Launch Chrome against localhost",
18+
"url":"http://localhost:8080",
19+
"webRoot":"${workspaceFolder}"
20+
}
21+
]
22+
}

‎1 functions/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<htmllang="en">
3+
<head>
4+
<metacharset="UTF-8">
5+
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
6+
<metaname="viewport"content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
11+
dfdsdfsd
12+
<scriptsrc="script1.js"></script>
13+
</body>
14+
</html>

‎1 functions/script1.js

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// f()
2+
// function f(){
3+
// console.log("hello")
4+
// }
5+
// f()
6+
7+
// Named functions / function expression
8+
// //f() // REferenceError: f is not defined
9+
// f = function func2(){
10+
// console.log("f2");
11+
// }
12+
// f()
13+
// //func2() // REferenceError: func2 is not defined
14+
15+
// f()// REferenceError: f is not defined
16+
// f = function (){
17+
// console.log("hello ");
18+
// }
19+
// f()
20+
21+
// parameters in functions
22+
// function add(a, b, c) {
23+
// console.log(a, b, c);
24+
25+
// return a + b + c;
26+
// }
27+
// console.log(add(1, 2));
28+
// console.log(add(1));
29+
// console.log(add(1, 2, 3));
30+
31+
//Arguments in Functions
32+
// function printAll() {
33+
// for (var i = 0; i < arguments.length; ++i) {
34+
// console.log(arguments[i]);
35+
// }
36+
// }
37+
// printAll("mango", "apple"); // Prints - mango apple
38+
39+
// printAll('fire', 'water', 'ice', 'gas'); // Prints - fire water ice gas
40+
41+
// function printAll(a,b) {
42+
// console.log(arguments.length)
43+
// console.log(a,b,arguments[0],arguments[1]);
44+
// for (var i = 0; i < arguments.length; ++i) {
45+
// console.log(arguments[i]);
46+
// }
47+
// }
48+
// printAll("mango", "apple"); // Prints - mango apple
49+
50+
// printAll("fire", "water", "ice"); // Prints - fire water ice gas
51+
52+
// default parameters
53+
// function findInterest(p, r = 5, t = 1) {
54+
// console.log("Interest over", t, "years is:", (p * r * t) / 100);
55+
// }
56+
// findInterest(1000); // Prints - Interest over 1 years is: 50
57+
// findInterest(1000, 7); // Prints - Interest over 1 years is: 70
58+
// findInterest(1000, 8, 2); // Prints - Interest over 2 years is: 160
59+
60+
// Rest Parameter / Var-args
61+
// function addAtLeastThree(a, b, c,...numbers) {
62+
// var sum = a + b + c;
63+
// for (var i = 0; i < numbers.length; ++i) {
64+
// sum += numbers[i];
65+
// }
66+
// return sum;
67+
// }
68+
// console.log(addAtLeastThree(10, 20, 30, 40, 50)); // Prints - 150
69+
70+
// console.log(addAtLeastThree(12,23,45)); //prints 80
71+
72+
// hoisting
73+
74+
// Varible hoisting
75+
76+
// console.log(a); //prints 'undefined' because only the variable declaration is moved to the top and not it’s definition
77+
// var a = 10
78+
79+
// function hoisting
80+
81+
// f()
82+
// function f(){
83+
// console.log("function hoisting")
84+
// }
85+
86+
// functions with in functions
87+
88+
// function outer(){
89+
// let i=0;
90+
// function middle(){
91+
// function inner(){
92+
// i=10
93+
// console.log("inner",i);
94+
// }
95+
// inner()
96+
// console.log("middle",i);
97+
98+
// }
99+
// //inner() // REference Error : inner is not defined
100+
// console.log("outer",i)
101+
// middle()
102+
// console.log("outer",i)
103+
// }
104+
// outer()
105+
106+
//function expression
107+
// var factorial = function fac(n) {
108+
// return n < 2 ? 1 : n * fac(n - 1);
109+
// };
110+
// console.log(factorial(3)); // print - 6
111+
// // console.log(fac(3)); // fac is not defined
112+
113+
// Anonymous Functions
114+
// console.log(factorial) // print undefined bcoz factorial is declared as undefined
115+
//console.log(factorial(3)); //function is not defined
116+
// var factorial = function (n) {
117+
// var ans = 1;
118+
// for (var i = 2; i <= n; i++)
119+
// ans *= i;
120+
// return ans;
121+
// }
122+
123+
// console.log(factorial(3));
124+
125+
126+
// passing funcions / Callbacks
127+
// function factorial(n){
128+
// let ans=1;
129+
// for(let i=1;i<=n;i++)
130+
// ans*=i;
131+
// return ans;
132+
// }
133+
134+
// var ncr = function(n,r,fact){
135+
// return fact(n)/(fact(r) * fact(n-r))
136+
// }
137+
// console.log(ncr(5,3,factorial))
138+
139+
// var ncr = function(n,r,fact){
140+
// return fact(n)/(fact(r) * fact(n-r))
141+
// }
142+
143+
//// following function is a callback functions passed to ncr()
144+
// console.log( ncr(5,3,function (n){
145+
// let ans=1;
146+
// for(let i=1;i<=n;i++)
147+
// ans*=i;
148+
// return ans;
149+
// })
150+
// );
151+
152+
//following function is passed as callback to another function
153+
// setTimeout(function(){
154+
// console.log("Timer 2 sec");
155+
// },2000)
156+

‎2 arrays/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<htmllang="en">
3+
<head>
4+
<metacharset="UTF-8">
5+
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
6+
<metaname="viewport"content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
11+
hello
12+
13+
<scriptsrc="script.js"></script>
14+
</body>
15+
</html>

‎2 arrays/script.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
//Create an array
3+
// a =[1,2,3];
4+
// console.log(a);
5+
// console.log(a.length);
6+
// console.log(a[0],a[5]);
7+
// a[5] = 34;
8+
9+
// console.log(a);
10+
// console.log(a[4]=33);
11+
// console.log(a)
12+
13+
// create an array using new keyword
14+
15+
//create pushes the element in the array
16+
// a = new Array(1,2,"raja")
17+
// console.log(a);
18+
// //create 2d array
19+
// a= new Array(a,a);
20+
// console.log(a)
21+
22+
// here 2 is the size of array
23+
// a = new Array(2);
24+
// console.log(a)
25+
26+
// here raja is element pushes in the array
27+
// a = new Array("raja");
28+
// console.log(a);
29+
30+
31+
//function methods
32+
// a = [12,"rajan",12/5]
33+
// console.log(a);
34+
// a.push(122) //push at the end
35+
// console.log(a);
36+
// a.pop() // Pop from the end
37+
// console.log(a);
38+
39+
// a.shift() // pop from the front
40+
// console.log(a);
41+
// a.unshift(99) // insert at front
42+
// console.log(a);
43+
44+
45+
// a = [12,23,43,56]
46+
47+
// a.splice(1,1); // delete 1 element form 1st index
48+
// console.log(a);
49+
// a.splice(1,0,"rajan","walia") // insert first element from 1st index
50+
// console.log(a);
51+
52+
// console.log(a.splice(2,23,122));
53+
// console.log(a);
54+
55+
56+
// iterating ver Arrays
57+
// a = [12,23,22,33]
58+
// for(let i=0;i<a.length;i++)
59+
// console.log(a[i])
60+
61+
62+
// console.log("\n")
63+
// function print(e){
64+
// console.log(e);
65+
// }
66+
// a.forEach(print);
67+
68+
// console.log("\n");
69+
// a.forEach(function (e) {
70+
// console.log(e)
71+
// })
72+
73+
// console.log("\n")
74+
// a.forEach((e)=>{ console.log(e)
75+
// })

‎3 hoisting/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<htmllang="en">
3+
<head>
4+
<metacharset="UTF-8">
5+
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
6+
<metaname="viewport"content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
9+
</head>
10+
<body>
11+
<scriptsrc="script.js"></script>
12+
</body>
13+
</html>

‎3 hoisting/script.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//var a=10 -- function scope
2+
// let a=10 -- block scope
3+
// a= 10 -- global scope
4+
// let a = 10;
5+
6+
7+
// function c(){
8+
// const b= 20;
9+
// {
10+
11+
// let b = 23;
12+
// console.log(b)
13+
// }
14+
// console.log(a)
15+
// }
16+
// //console.log(b)
17+
// c()
18+
19+
// console.log(b); // undefined bcoz b declared not defined
20+
// var b= 10;
21+
l=10;
22+
23+
console.log(l)
24+
25+
a();
26+
//b() // can't access here
27+
//console.log(a)
28+
console.log(c)
29+
c=333;
30+
functiona(){
31+
if(1){
32+
d=20;//
33+
}
34+
}
35+
36+
37+
b=function(){
38+
c=30;
39+
console.log("hello ",c);
40+
}
41+
console.log(c)
42+
//a()
43+
//console.log(typeof a)
44+
b()//
45+
46+
console.log(c)

‎4 objects/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<htmllang="en">
3+
<head>
4+
<metacharset="UTF-8">
5+
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
6+
<metaname="viewport"content="width=device-width, initial-scale=1.0">
7+
<title>Objects</title>
8+
</head>
9+
<body>
10+
<scriptsrc="script.js"></script>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp