Point class with toString() - Node.js Object

Node.js examples for Object:Class Definition

Description

Point class with toString()

Demo Code



function Point(x,y){
  this.x = x;//  w  ww  .ja va  2  s. c  om
  this.y = y;
}

Point.prototype.toString = function () {
  return '(' + this.x + ', ' + this.y + ')';
}
var point = new Point(6,3);
console.log(point.toString());//(6,3)

Related Tutorials