var tools = {}; tools.triangle = function() { var originX = 0; var originY = 0; }
var tools = {}; tools.triangle =
In the first example, X and Y both exist as local variables to the closure saved in the variable triangle.
triangle
In the second example, X and Y exist as variables to the object tools.triangle because of the use of this.
tools.triangle
this