add topic_5
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>closure</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
function a7(b) {
|
||||
return function () {
|
||||
return b -= 7;
|
||||
}
|
||||
}
|
||||
|
||||
const a = a7(100)
|
||||
|
||||
console.log(a())
|
||||
console.log(a())
|
||||
|
||||
console.log("hello")
|
||||
|
||||
function printMap(obj, func) {
|
||||
return function (...args) {
|
||||
func.apply(obj, args);
|
||||
}
|
||||
}
|
||||
|
||||
person = {name: "Вова"}
|
||||
function logPerson() {
|
||||
console.log(`${this.name}`)
|
||||
}
|
||||
|
||||
const f = printMap(person, logPerson)
|
||||
f()
|
||||
|
||||
function printNumbers(from, to) {
|
||||
let timerId = setInterval(function() {
|
||||
if (from >= to) {
|
||||
console.log(from)
|
||||
from -= 1
|
||||
}
|
||||
if (from < to) {
|
||||
clearTimeout(timerId);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
printNumbers(10, 5)
|
||||
Reference in New Issue
Block a user