Q:

Javascript inheritence .Why does my class share nested member data?

I am having difficulty with the following inheritance code that I read in Crockfords book.
When I create two instances of a Column object the "this.name" member data is different in each instance, as I would have expected.
However, when I use nested member data "this.model.name" it is always shared among the instances.
Can anyone suggest a way to fix this?
var BaseColumn = function() {
   this.model = {};
   this.model.name = "";
   this.name="";
};

var Column = function (name) {
   this.model.name = name;
   this.name = name;
};

Column.prototype = new BaseColumn();

var col1 = new Column("Column1");
var col2 = new Column("Column2");

alert(col1.name);          //Returns "Column1"
alert(col2.name);          //Returns "Column2"
alert(col1.model.name);    //Returns "Column2"
alert(col2.model.name);    //Returns "Column2"

A:

This is because every instance of Column will have a reference to the SAME model object in the prototype.  Creating the second Column overwrites the previous value of model.name.
Let's look at your code more closely to see why you are getting what you are:
var BaseColumn = function() {
   this.model = {};
   this.model.name = "";
   this.name="";
};

This creates a type BaseColumn constructor that will create properties model and name on the new object when invoked using new.
var Column = function (name) {
   this.model.name = name;
   this.name = name;
};

This creates a type Column constructor that will fail.  If you called new Column() now, it would fail on this.model (at this moment).
Column.prototype = new BaseColumn();

This REPLACES the existing prototype with a NEW prototype created from a new instance of BaseColumn.  This object contains the properties I mentioned above for this type, and the property values will be SHARED across ALL Column objects.  Why?  Because if the local Column instance (col1 or col2) doesn't contain a property, the prototype chain is searched for one.  Since all Column instances shared the same prototype, they all end up referencing the same values.
var col1 = new Column("Column1");

Did you know that at this point, Column.prototype.model.name == "Column1"?
var col2 = new Column("Column2");

Column.prototype.model.name is now  "Column2"`.  You see, the prototype is NOT duplicated.  It is SHARED.
If the desire is to have one model per instance, you will have to construct a new model object for each new Column.
For a better way to approach inheritance, take a look at the answer by Juan Mendes.  In this pattern, you are calling the base constructor explicitly from the constructor of your sub type.  This will add/construct the base properties, and should be placed at the top of the sub type's constructor (usually).

A:

The answer provided by James Wilkins is correct. There is only one instance of BaseColumn being created and it's shared by all instances of Columns through Column.prototype
However, it's worth noting that your way of establishing inheritance is incorrect.  There's no need to instantiate a parent just to set up inheritance, and you need to call the parent's constructor from your constructor.
See my posts at http://js-bits.blogspot.com/2010/08/javascript-inheritance-done-right.html and http://js-bits.blogspot.com/2014/10/understanding-prototypical-inheritance.html for further details
The following example works fine.

    var BaseColumn = function() {
      this.model = {};
      this.model.name = "";
      this.name = "";
    };

    var Column = function(name) {
      // Call the parent's constructor, a new model object will be created
      // instead of using a shared one from the prototype
      BaseColumn.apply(this);
      this.model.name = name;
      this.name = name;
    };

    Column.prototype = Object.create(BaseColumn.prototype);

    var col1 = new Column("Column1");
    var col2 = new Column("Column2");

    console.log(col1.name); //Returns "Column1"
    console.log(col2.name); //Returns "Column2"
    console.log(col1.model.name); //Returns "Column1"
    console.log(col2.model.name); //Returns "Column2"

