Object with properties - Node.js Object

Node.js examples for Object:Property

Description

Object with properties

Demo Code


function Phone(brand, price, color) {
      function Phone(brand, price, color) {
    this.brand = brand; //from w ww  .  j a  va 2  s  .c  o m
    this.price = price;
    this.color = color;
  }
}

Phone.prototype.printInfo = function() {
    console.log("The phone brand is " + this.brand + ", color is " + this.color + " and the price is " + this.price + ".");
}

function Phone(brand, price, color) {
  this.brand = brand; 
  this.price = price;
  this.color = color;
}
Phone.prototype.printInfo = function() {
  console.log("The phone brand is " + this.brand + ", color is " + this.color + " and the price is " + this.price + ".");
}

var iPhone6S = new Phone("Apple", 2250, "silver");

iPhone6S.printInfo();

console.log()

Related Tutorials