-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
57 lines (43 loc) · 1019 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const array = [1, 2, 3];
const newArray = array.map((item) => {
return item ** 2;
})
console.log(newArray)
const [a, ,b] = ['hola', 2, 'mundo']
console.log(`${a} - ${b}`)
const { hola, num } = {
hola: 'hola mundo :)',
num: 2018
}
console.log(`${hola} -> número ${num}`)
// Component react
const HelloWorld = (props) => {
return (
<div>
<h4>Hello world! :)</h4>
<p>{props.name}</p>
</div>
)
}
const app = document.getElementById('app');
ReactDOM.render(<HelloWorld name='John Serrano' />, app);
// Async/Await
const resolveAfter2Seconds = () => {
return new Promise(resolve => {
setTimeout(() => {
resolve('resolved');
}, 2000);
});
}
// async function asyncCall() {
// console.log('calling');
// var result = await resolveAfter2Seconds();
// console.log(result);
// // expected output: "resolved"
// }
const asyncCall = async () => {
console.log('calling');
const result = await resolveAfter2Seconds();
console.log(result);
}
asyncCall();