Add Point#clone docs to Point.js.

This commit is contained in:
Jonathan Puckey 2011-02-24 14:31:32 +01:00
parent ebbf8cf039
commit 95f9028091

View file

@ -33,6 +33,21 @@ var Point = Base.extend({
}
},
/**
* Returns a copy of the point.
* This is useful as the following code only generates a flat copy:
*
* <code>
* var point1 = new Point();
* var point2 = point1;
* point2.x = 1; // also changes point1.x
*
* var point2 = point1.clone();
* point2.x = 1; // doesn't change point1.x
* </code>
*
* @return the cloned point
*/
clone: function() {
return Point.create(this.x, this.y);
},