Skip to content

Commit 40c74d5

Browse files
committed
callbacks
1 parent 214bc6e commit 40c74d5

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

Ejemplos/callbacks.html

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
11+
<h3>CallBacks</h3>
12+
<div id="letras"></div>
13+
</body>
14+
15+
<script>
16+
const letras = ['Aa','Bb','Cc','Dd'];
17+
18+
//Inline Callback => Se le llama asi porque la funcion no tiene nombre
19+
/*
20+
letras.forEach(function(letra){
21+
console.log(letra);
22+
})
23+
*/
24+
25+
26+
//
27+
/*
28+
function callback(letra){
29+
console.log(letra);
30+
}
31+
letras.forEach(callback);
32+
*/
33+
34+
35+
function nuevaLetra(letra, callback){
36+
setTimeout(function(){
37+
letras.push(letra);
38+
callback();
39+
},2000);
40+
}
41+
42+
function mostrarLetras(){
43+
setTimeout(function(){
44+
let html='';
45+
letras.forEach(function(letra){
46+
html += `<p>${letra}</p>`;
47+
})
48+
document.getElementById('letras').innerHTML = html;
49+
},1000);
50+
51+
}
52+
53+
nuevaLetra('Ee',mostrarLetras);
54+
55+
mostrarLetras();
56+
</script>
57+
</html>

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,9 @@ class Casa {
855855
}
856856
```
857857

858+
## Async JavaScript
859+
860+
858861

859862
---
860863
# JavaScript FUNCIONES VARIAS

0 commit comments

Comments
 (0)