Skip to content

Instantly share code, notes, and snippets.

@Hollyw00d
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hollyw00d/0f8f8c87119761075565 to your computer and use it in GitHub Desktop.
Save Hollyw00d/0f8f8c87119761075565 to your computer and use it in GitHub Desktop.
Object Method Clarification Needed
// From "Constructors with Methods" > 24/33 > Objects I > CodeAcademy.com
// QUESTIONS:
// 1. In line 19, why does the [rex] property, which is assigned to the [area] object, get a [calcArea] value? Or is it called a [calcArea] method of the [rex] property?
function Rectangle(height, width) {
this.height = height;
this.width = width;
this.calcArea = function() {
return this.height * this.width;
};
// put our perimeter function here!
this.calcPerimeter = function() {
return this.height * 2 + this.width * 2;
};
}
var rex = new Rectangle(7,3);
var area = rex.calcArea();
var perimeter = rex.calcPerimeter();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment