Skip to content

Instantly share code, notes, and snippets.

@soharu
Last active January 2, 2016 09:09
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 soharu/8281553 to your computer and use it in GitHub Desktop.
Save soharu/8281553 to your computer and use it in GitHub Desktop.
Example of Constructor Overloading
function Set() {
this.values = {};
this.n = 0;
if (arguments.length == 1 && isArrayLike(arguments[0]))
this.add.apply(this, arguments[0]);
else if (arguments.length > 0)
this.add.apply(this, arguments);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment