Refactor for JS best practices

- No need to return `this` from constructor
- Guard against missing `new` operator
- Move instance methods onto the prototype (saves memory and makes code
cleaner).