-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjetos.html
More file actions
74 lines (47 loc) · 1.55 KB
/
Copy pathobjetos.html
File metadata and controls
74 lines (47 loc) · 1.55 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
/* dentro de un objeto a las variables
se van a llamar atributos/propiedades y a
las funciones se les llama metodos */
const persona = {
nombre: "Christian",
apellido: "londono",
edad: 27,
pasatiempo: ["TocarTrombone","MontarBici","Estudiar"],
soltero: false,
contacto: {
email:"cristian@gmail.com",
facebook:"clm",
celular:"235455236",
},
saludar: function(){console.log("Hola")},
decrirMiNombre: function(){
console.log(`Hola me llamo ${this.nombre} ${this.apellido} y tengo ${this.edad} años y me puedes llamar al ${this.contacto.celular}`)
}
}
console.log(persona);
console.log(persona["nombre"]);
console.log(persona["apellido"]);
console.log(persona.nombre);
console.log(persona.apellido);
console.log(persona.soltero);
console.log(persona.soltero);
console.log(persona.pasatiempo);
console.log(persona.pasatiempo[1]);
console.log(persona.contacto);
console.log(persona.contacto.celular);
persona.saludar()
persona.decrirMiNombre()
console.log(Object.keys(persona))
console.log(Object.values(persona))
console.log(persona.hasOwnProperty("nombre"))
console.log(persona.hasOwnProperty("apellido"))
</script>
</body>
</html>