-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path08_funtions.js
More file actions
56 lines (43 loc) · 1.21 KB
/
Copy path08_funtions.js
File metadata and controls
56 lines (43 loc) · 1.21 KB
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
// ##########################
// CREACION DE FUNTIONS EN JS
// ##########################
// Declaracion de funcion (Funtion Declaration)
function saludar() {
console.log("Hola")
}
// Expresion de funcion (Funtion Expression)
const saludarV2 = function () {
console.log("Hola");
}
// Llamado de funcion
saludar() // Hola
saludarV2() // Hola
// #########################
// PARAMETROS EN LA FUNTIONS
// #########################
function sumar(num1, num2) {
console.log(num1 + num2)
}
sumar(2, 3) // 5
sumar(28, 3) // 31
// Parametros por default
const saludarV3 = function (nombre = "desconocido") {
console.log(`hola ${nombre}`)
}
saludarV3() // hola desconocido
saludarV3("mario") // hola mario
// ####################################
// ARROW FUNTIONS (FUNCIONES DE FLECHA)
// ####################################
function funcionNormal() {
console.log("esta es una funcion declarativa")
}
const funcionExpresiva = function () {
console.log("esta es una funcion expresiva")
}
const funcionDeFlecha = () => {
console.log("Esta es una arrow funtion")
}
funcionNormal() // esta es una funcion declarativa
funcionExpresiva() // esta es una funcion expresiva
funcionDeFlecha() // Esta es una arrow funtion