Search code examples
javascriptobject-literal

What is wrong on my javascript object-literal instance?


I'm trying to instance a object-literal on my javascript code, but is not working.

    var user = {
        name = "User Name",
        email = "user@teste.com",
        birthdate = new Date(1980,1,30)
    };

    console.log(user);

Solution

  • If you're assigning values within the object, use : You can assign values outside of the object with user.name = "User Name"

        var user = {
            name : "User Name",
            email : "user@teste.com",
            birthdate : new Date(1980,1,30)
        };
    
        console.log(user);