-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cecd667
commit 12e44a2
Showing
28 changed files
with
792 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "chrome", | ||
"request": "launch", | ||
"name": "Launch Chrome against localhost", | ||
"url": "http://localhost:8080", | ||
"webRoot": "${workspaceFolder}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>dyamicelementcreateusingdom</title> | ||
</head> | ||
<body> | ||
<button id="btn"> Click me</button> | ||
<button id="btn1"> Click me</button> | ||
<button id="btn2">Click me</button> | ||
<script src="dynamicelementcreate.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const btn= document.querySelector('#btn') | ||
btn.addEventListener('click',()=> | ||
{ | ||
const head1= document.createElement('h1') | ||
head1.setAttribute('id','heading') | ||
head1.innerHTML='this is heading' | ||
document.body.appendChild(head1) | ||
|
||
}) | ||
btn1.addEventListener('click',()=> | ||
{ | ||
const ul= document.createElement('ul') | ||
const li=document.createElement('li') | ||
ul.setAttribute('id','unordered') | ||
ul.appendChild(li) | ||
li.innerText='added unordered list' | ||
document.body.appendChild(ul) | ||
}) | ||
let count=1 | ||
btn2.addEventListener('click',()=> | ||
{ | ||
const li= document.createElement('li') | ||
li.innerText=count; | ||
document.body.appendChild(li) | ||
count=count+2; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Iterator Pattern Genearator Function #YIELD Keyword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//Built-in iterator | ||
for(const val of [1,2,3,4,5]){ | ||
console.log(val) | ||
} | ||
//YIELD | ||
function *create(){ | ||
console.log('how') | ||
yield 'many'; | ||
console.log('coding') | ||
yield 'community'; | ||
} | ||
const cr=create() | ||
/*console.log(cr.next().value) | ||
console.log(cr.next().value)*/ | ||
|
||
for(let val of cr){ | ||
console.log(val) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
(function add(a,b){console.log(a+b)})(2,3); | ||
|
||
(function print(){console.log("hello")})(); | ||
|
||
(()=>console.log('hii'))(); | ||
|
||
const divide =((a,b)=> a/b)(4,2); | ||
console.log(divide); | ||
|
||
|
||
const value=(()=>100)(); | ||
console.log(value) | ||
|
||
// Regular Function | ||
function add(a,b){ | ||
console.log(a+b) | ||
} | ||
add(2,3) | ||
|
||
|
||
// Arrow function | ||
const a=()=>{ | ||
console.log(26) | ||
} | ||
|
||
// Regular IIFE | ||
(function something(){ | ||
console.log('something but nothing') | ||
})(); | ||
|
||
//Anonymous IIFE | ||
(function Do(){ | ||
console.log('Arrow IIFE') | ||
})(); | ||
|
||
//arrow IIFE | ||
(arrow=()=>{ | ||
console.log('Arrow IIFE') | ||
})(); | ||
|
||
let age=25; | ||
arrow=(()=>{ | ||
age=27; | ||
console.log(age+1); | ||
})(); | ||
|
||
|
||
const val= ((a,b)=> a-b)(9,9); | ||
console.log(val) | ||
/* | ||
const multiply =((a,b)=>{return a*b}) | ||
(3,2); | ||
console.log(multiply); | ||
*/ | ||
//atm | ||
/* | ||
const atm= function(startBal){ | ||
let bal= startBal; | ||
function withdraw(amt){ | ||
if(amt>bal){ | ||
throw err; | ||
} | ||
else{ | ||
bal-=amt; | ||
return bal; | ||
} | ||
} | ||
return {withdraw}; | ||
}; | ||
const mahima= atm(2000) | ||
console.log(mahima.withdraw(200)) | ||
*/ | ||
|
||
|
||
const x='xyz'; | ||
const hi=()=>"hii"; | ||
(()=>{ | ||
const x='lol'; | ||
const hi=()=>"hello"; | ||
console.log(x); | ||
console.log(hi()); | ||
})(); | ||
|
||
|
||
// Private variable and methods from closure | ||
const increment=(()=>{ | ||
let counter=0 | ||
console.log(counter) | ||
const credits=(num)=>console.log(`I have ${num} credits `) | ||
return ()=> {++counter; credits(counter);} | ||
})(); | ||
increment() | ||
|
||
// Module Pattern | ||
const Score =(()=>{ | ||
let count=0 | ||
return { | ||
current:()=>{return count}, | ||
increment:()=>{count ++}, | ||
reset:()=>{count=0} | ||
} | ||
})(); | ||
Score.increment() | ||
console.log(Score.current()) | ||
Score.increment() | ||
console.log(Score.current()) | ||
Score.reset() | ||
console.log(Score.current()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Promisifiication</title> | ||
</head> | ||
<body> | ||
<h1>Promisification</h1> | ||
<script src="index.js"></script> | ||
<script src="test.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function loadScript(src,callback){// src--it will give script urland callback will give callback function | ||
const script= document.createElement('script') | ||
script.src=src; | ||
script.onload=()=>callback(null,script) | ||
script.onerror=(err)=>callback(err) | ||
document.head.appendChild(script) | ||
|
||
|
||
} | ||
loadScript('test.js',(err,script)=>{ | ||
if(err){ | ||
console.log(err) | ||
} | ||
else{ | ||
console.log('script loaded') | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('hello lolo') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const arr=[2,4,6,8,133] | ||
const res = arr.forEach((item) => { | ||
return item * item; | ||
}); | ||
|
||
// it will return new array after performing operation | ||
const ret= arr.map((val)=>{ | ||
return val *val | ||
}) | ||
console.log(ret) | ||
//console.log(typeof ret) | ||
|
||
// array of object | ||
const arrObj=[ | ||
{ | ||
name:'Raj', | ||
age:22, | ||
profession:'Mern Stack' | ||
}, | ||
{ | ||
name:'kiara', | ||
age:28, | ||
profession:' Software Engineer' | ||
}, | ||
{ | ||
name:'sheena', | ||
age:30, | ||
profession:'Frontend developer' | ||
}, | ||
{ | ||
name:'Preeti', | ||
age:30, | ||
profession:'Frontend developer' | ||
}, | ||
{ | ||
name:'Mayank', | ||
age:37, | ||
profession:'Frontend developer' | ||
}, | ||
{ | ||
name:'ram', | ||
age:70, | ||
profession:'software developer' | ||
}, | ||
] | ||
|
||
const newArr= arrObj.filter((val)=>{ | ||
return val.profession=='Frontend developer'; | ||
}) | ||
console.log(newArr) | ||
|
||
|
||
const red= arr.reduce((curr,total,index,array)=>{ | ||
|
||
return curr | ||
}) | ||
console.log(red) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>closure</title> | ||
</head> | ||
<body> | ||
<h1 id="closure" style="font-size: 80px;">closure</h1> | ||
<button id="btn">Click me</button> | ||
<script src="index.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.