SOURCE

var Dog = function(name) {
	this.name = name;
  
  this.getName = function() {
  	return this.name;
  }
};

Dog.prototype.sayHi = function() {
	console.log("汪汪汪! 我叫 " + this.getName());
};

var snoopy = new Dog("SNOOPY");
snoopy.sayHi();

console.log(snoopy.getName());
console 命令行工具 X clear

                    
>
console