Introduction to Object-II


whats the solution ?its keep on saying syntax error?
i dont think so there is any syntax error.

var james = {
    // add properties to this object!

function Person(job, married)
    this.job = job;
    this.married = married;

// create a "gabby" object using the Person constructor!
var gabby = new Person("student", true);


There are two ways to create objects with properties and you combined both, which is incorrect.

For literal notation you should write it like this:

var james = {
   job: "programmer",
   married: false

Usually you use this when your object must have a set of properties defined at the start.

For dot notation you write it like this:

var james = new Object();
james.job = "programmer";
james.married = false;

Dot notation is commonly used to access and create/modify properties along the way. You can start by creating the empty object first, then assigning or modifying properties. You can also use it after you've created an object via literal notation.


Thanks a lot its working.