Allow creating instance without new

This commit is contained in:
Yemel Jardi 2014-12-01 16:02:06 -03:00
parent 69aec2fd4d
commit 3208ca2a44
1 changed files with 4 additions and 0 deletions

View File

@ -23,6 +23,10 @@
*/
function Unit(amount, code) {
if (!(this instanceof Unit)) {
return new Unit(amount, code);
}
this._value = this._from(amount, code);
var self = this;