Skip to content

Instantly share code, notes, and snippets.

@matthewstokeley
Last active April 12, 2019 15:25
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 matthewstokeley/5480db67b977eeefa42cc4c3025f0647 to your computer and use it in GitHub Desktop.
Save matthewstokeley/5480db67b977eeefa42cc4c3025f0647 to your computer and use it in GitHub Desktop.
Three different methods for handling constructors

Constructors

Prototypal Javascript

https://bitbucket.org/matthewjaestokeley/js-framework/src/master/src/domain.js

Make use the of the built-in prototype property to assign properties and methods.

Pojo (plain old javascript object)

https://github.com/matthewstokeley/js-select/blob/master/index.js

Use a pojo - or a plain old Javascript object - and encapsulate initialization functions in a function.

es2016

https://github.com/matthewstokeley/js-labels/blob/master/Label.js

Use the updated syntax with the constructor method defined inside a class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment