//DATE OBJECTS

//Date(year, month, day, hours, minutes, seconds, milliseconds)
const today = new Date();
console.log(today);
console.log(today.toLocaleDateString());
console.log(today.toLocaleTimeString());
console.log(today.toDateString());
console.log(today.toTimeString());
console.log(today.getTime());


//CLOSURES              by using closures we can reuse a function without having to create a new one. And with this we an store variables safely.

function createCounter(){
    let count = 0;
    function increment(){
        count++;
        console.log(count);
    }

    function getCount(){
        return count;
    }
    return {increment};
}

counter = createCounter();
counter.increment();
counter.increment();
counter.increment();


//SETTIMEOUT        Note this function is not too precise!

function hello(){
    console.log("HOLA");
}

setTimeout(hello, 3000);        //It will delay the function by 3 seconds
setTimeout( function(){console.log("HOLA")}, 3000);
setTimeout(() => window.alert("HOLA"), 3000);

console.log("HOLA");

