Skip to content

Instantly share code, notes, and snippets.

@berewt
Created November 15, 2016 11:42
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 berewt/434d474cc61089d35ff9a34f99d8e352 to your computer and use it in GitHub Desktop.
Save berewt/434d474cc61089d35ff9a34f99d8e352 to your computer and use it in GitHub Desktop.
$ node --version
v6.9.1
$ node
> bar = {MyClass: function (x) {this.x = x}}
{ MyClass: [Function: MyClass] }
> foo = {MyClass(x) {this.x = x}}
{ MyClass: [Function: MyClass] }
> new bar.MyClass(2)
MyClass { x: 2 }
> new foo.MyClass(2)
TypeError: foo.MyClass is not a constructor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment