title: Javascript call to chain constructors for an object
body: <p>1) call</p>
  
  <pre><code>var obj = {num:2};
  
  var add = function(a){
      return this.num + a;
  };
  
  add.call(obj, 1); //function.call(obj, arg)
  </code></pre>
  
  <p>2) call to chain constructors for an object.</p>
  
  <pre><code>var Product = function (name, price) {
      this.name = name;
      this.price = price;
  }
  
  var Food = function(name, price) {
      Product.call(this, name, price); // &lt;-- 1. Product is obj constructor not fun
                                       //     2. what is 'this' here?
      this.category = 'food';
  }
  
  var cheese = new Food('feta', 5);
  
  console.dir(cheese);
  </code></pre>
  
  <p>I'm currently study javascript oop, I found an example about <code>Function.prototype.call()</code> chain constructors, but I don't understand how it works.</p>
  
  <p>1) isn't call required function call obj? but Product is construct.</p>
  
  <pre><code>var food = { category : 'food' };
  
  var Product = function (name, price) {
      this.name = name;
      this.price = price;
  }
  
  var cheese = Product.call(food);
  console.dir(cheese);//this will become undefine
  </code></pre>
  
  <p>2) what is 'this'? Food object? <code>Product.call(new Food, name, price);</code>?</p>
  
  <p>*final result <code>var cheese</code> will be an object, <code>Product.call(new Food obj, name, price)</code></p>
  
  <p>Product still a function, why result become an object?</p>