const

const works a bit like constants in Ruby. Once defined, it cannot be updated or redefined.

const greeter = "Say hi!";
const greeter = "Hello world!";    //ERROR
greeter = "Hello world!";    //ERROR

const hashes

However, constants can also be used to define hashes:

const greeter = {
message: "Say hi!"
times: 4
}

While we cannot redefine the hashes:

const greeter = {
message: "Hello world!"
times: 3
}
//ERROR!!!!!!!!!!!!!!

We can update the key value pairs like so:

greeter.message = "Hello world!";

results matching ""

    No results matching ""