File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change @@ -855,6 +855,9 @@ class Casa {
855855 }
856856```
857857
858+ ## Async JavaScript
859+
860+
858861
859862---
860863# JavaScript FUNCIONES VARIAS
You can’t perform that action at this time.
0 commit comments