-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
9342c22
commit 4d27dc1
Showing
1 changed file
with
74 additions
and
0 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,74 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Closure aur chai</title> | ||
</head> | ||
<body style="background-color: #313131;"> | ||
<button id="orange">Orange</button> | ||
<button id="green">Green</button> | ||
</body> | ||
|
||
<script> | ||
// function init() { | ||
// let name = "Mozilla"; | ||
// function displayName() { | ||
// console.log(name); | ||
// } | ||
// displayName(); | ||
// } | ||
// init(); | ||
|
||
// function outer(){ | ||
// let username = "hitesh" | ||
// console.log("OUTER", secret); | ||
// function inner(){ | ||
// let secret = "my123" | ||
// console.log("inner", username); | ||
// } | ||
// function innerTwo(){ | ||
// console.log("innerTwo", username); | ||
// console.log(secret); | ||
// } | ||
// inner() | ||
// innerTwo() | ||
|
||
// } | ||
// outer() | ||
// console.log("TOO OUTER", username); | ||
|
||
|
||
// function makeFunc() { | ||
// const name = "Mozilla"; | ||
// function displayName() { | ||
// console.log(name); | ||
// } | ||
// return displayName; | ||
// } | ||
|
||
// const myFunc = makeFunc(); | ||
// myFunc(); | ||
|
||
</script> | ||
<script> | ||
// document.getElementById("orange").onclick = function(){ | ||
// document.body.style.backgroundColor = `orange` | ||
// } | ||
// document.getElementById("green").onclick = function(){ | ||
// document.body.style.backgroundColor = `green` | ||
// } | ||
|
||
function clickHandler(color){ | ||
// document.body.style.backgroundColor = `${color}` | ||
|
||
return function(){ | ||
document.body.style.backgroundColor = `${color}` | ||
} | ||
} | ||
|
||
document.getElementById('orange').onclick = clickHandler("orange") | ||
document.getElementById('green').onclick = clickHandler("green") | ||
|
||
</script> | ||
</html> |