Created
January 29, 2012 03:48
-
-
Save island205/1697043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Vector; | |
Vector = (function() { | |
/* | |
构造函数这里使用了默认参数和属性参数 | |
*/ function Vector(x, y) { | |
var vector; | |
this.x = x != null ? x : 0; | |
this.y = y != null ? y : 0; | |
if (typeof this.x === "object") { | |
/* | |
这里的vector为了解决给@x赋值的问题,当然使用 | |
@[email protected] | |
@[email protected] | |
同样可以,不过代码清晰或者更好点 | |
*/ | |
vector = this.x; | |
this.x = vector.x; | |
this.y = vector.y; | |
} | |
} | |
return Vector; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment