My Feed
Create Team Blog
Let's kick off a fresh team blog! Bring on the crew and let's get to publishing.

call method in javascript !!

Default profile photo
·Oct 15, 2018
// using call to chain constructor 

function Product(name, price) { = name;
  this.price = price;

function Food(name, price) {, name, price);
  this.category = 'food';

function Toy(name, price) {, name, price);
  this.category = 'toy';

var cheese = new Food('feta', 5);
var fun = new Toy('robot', 40);

// code is working fine ,but one thing I am unable to understand that if we omit this from the line, name, price) to, price) then also same output is coming so I was thinking what is need to write this then in above call