Question: The book I am learning from says the following code is creating an object, but I am unsure as to how this works. The second section of code is another way I have learned, from an online tutorial. But what is the difference?
I have tried to research this myself but am quite new to all of this and some of the explanations I do not understand. Are there advantages/disadvantages to using each one? Thanks in advance.

```
function Player (name , score , rank)
{
this.name = name ;
this.score = score ;
this.rank = rank ;
}
var playerOne = new Player ( "Craig" , 199 , "1st" ) ;

```

The following is the way I had done it previously ;

```
var playerOne = {name: "Craig" , score: 199 , rank: "1st"} ;
var playerTwo = {name: "Tohny" , score: 155522 , rank: "2nd"} ;

```

Answer: 
Main difference is that the first one will have an extra object in its "prototype chain". The prototype chain is how you do inheritance in JavaScript. 

Therefore, you can extend that object, and all the objects created from the `Player` constructor function will inherit those items.

```
function Player (name , score , rank)
{
this.name = name ;
this.score = score ;
this.rank = rank ;
}

Player.prototype.getNameRank = function() {
    return this.name + ":" + this.rank;
};

var playerOne = new Player ( "Craig" , 199 , "1st" ) ;

```

So now the `playerOne` object will inherit the `getNameRank()` method, while other objects created using the object literal syntax will be unaffected.

```
var nr = playerOne.getNameRank();

console.log(nr); // Craig:1st

```

---

All *(well most anyway)* objects that you create in JavaScript will inherit from the `Object.prototype` object. The object literal syntax in your second example has that object, and only that object, behind itself in the prototype chain.

The object from the constructor first has `Player.prototype` and then `Object.prototype`.
The first code example is a constructor. From what I understand, it's a more strongly-typed way of creating objects since the parameters and members of that object are already defined.

The second code example *does* do the same thing, however there's nothing defining what the object should actually contain or how it should behave. It's not exactly a bad thing, but for some situations it's far less preferable and doesn't give you as much versatility as a constructor would.