Objetos: datos con nombre
Las listas guardan cosas en orden. Los objetos las guardan con etiqueta, y eso cambia todo.
Objects: data with names
Lists store things in order. Objects store them with labels, and that changes everything.
Imagina guardar los datos de un jugador con una lista:
let jugador = ["Joaco", 1500, 3];
¿Qué es el 1500? ¿Puntos, monedas, milisegundos? ¿Y el 3, vidas o nivel? Tendrías que recordar el orden exacto para siempre.
Un objeto le pone nombre a cada dato. Se escribe entre llaves
{ }, con nombre: valor.
Imagine storing a player's data with a list:
let player = ["Joaco", 1500, 3];
What is 1500? Points, coins, milliseconds? And the 3, lives or level? You would have to remember the exact order forever.
An object gives each value a name. Written between braces { },
as name: value.
Cada dato se llama propiedad, y se pide con un
punto: jugador.puntos. Se lee solo, sin recordar ningún orden.
Each value is called a property, and you ask for
it with a dot: player.points. It reads by itself, no order to remember.
Funcionan igual que las variables: puedes leerlas, cambiarlas y hasta crear nuevas sobre la marcha.
They work like variables: you can read them, change them, and even create new ones on the fly.
Acá es donde se juntan las dos ideas, y es como está armado prácticamente todo el software que existe: una lista de objetos.
Una tabla de puntajes, un carrito de compras, los mensajes de un chat, los enemigos de un nivel. Todos son esto.
This is where the two ideas meet, and it is how practically all existing software is built: a list of objects.
A scoreboard, a shopping cart, chat messages, the enemies in a level. All of them are this.
Variables, decisiones, bucles, funciones, listas y objetos. Con eso está construido todo el software que has usado en tu vida.
Lo que viene ahora es distinto: cómo hacer que esto se vea en una página web. Empezamos por HTML, que es la estructura.
Variables, decisions, loops, functions, lists and objects. Every piece of software you have ever used is built from these.
What comes next is different: how to make this appear on a web page. We start with HTML, the structure.