Fechas y expresiones regulares
Dos herramientas que cierran el curso: manejar el tiempo, y buscar patrones dentro de texto.
Dates and regular expressions
Two tools that close out the course: handling time, and finding patterns inside text.
new Date() crea un objeto con la fecha y hora exactas de ahora mismo. Tiene
métodos para sacar cada parte por separado.
new Date() creates an object with the exact date and time right now. It has
methods to pull out each part separately.
También puedes crear una fecha puntual, y restar dos fechas para saber cuánto tiempo hay entre ellas —el resultado viene en milisegundos, así que hay que convertirlo.
You can also create a specific date, and subtract two dates to find how much time sits between them — the result comes in milliseconds, so it needs converting.
Una expresión regular describe una forma de texto, entre barras
/ /. .test() responde solo true o
false: ¿el texto calza con el patrón?
A regular expression describes a text shape, between slashes
/ /. .test() answers only true or
false: does the text match the pattern?
Sobre un texto, .match() te devuelve las coincidencias, y
.replace() las reemplaza. Con la marca g al final del patrón
("global"), se aplica a todas las coincidencias, no solo la primera.
On a string, .match() returns matches, and .replace() replaces
them. With the g flag at the end of the pattern ("global"), it applies to every
match, not just the first.
Desde qué es programar hasta expresiones regulares: variables, decisiones, bucles, funciones, el DOM, canvas, clases, promesas, y ahora fechas y patrones de texto. Con esto tienes lo necesario para construir prácticamente cualquier cosa en el navegador.
Si te interesa el otro lado —análisis de datos, automatización, inteligencia artificial— ahí está el curso de Python. Vas a reconocer casi todas las ideas; solo cambia cómo se escriben.
From what programming is to regular expressions: variables, decisions, loops, functions, the DOM, canvas, classes, promises, and now dates and text patterns. With this you have what you need to build practically anything in the browser.
If the other side interests you — data analysis, automation, artificial intelligence — there is the Python course. You will recognise almost every idea; only the writing changes.