Skip to content

Instantly share code, notes, and snippets.

@joepie91
Last active June 25, 2023 09:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joepie91/17cd52d8c8b71e376e06 to your computer and use it in GitHub Desktop.
Save joepie91/17cd52d8c8b71e376e06 to your computer and use it in GitHub Desktop.
Why ES6 > * (but not really)
var inherits = require('utils').inherits
var Model = require('some-orm').Model
function User () {
Model.call(this)
}
inherits(User, Model)
Model.prototype.getName () {
return this._name
}
let Model = require('some-orm').Model
class User extends Model {
get name() {
return this._name
}
}
var Model = Object.create(null); // you didn't actually specify any properties...
var User = Object.create(Model, {
name: { // same syntax as defineProperty. extra newlines for clarity.
get: function() {
// getters/setters like this are unnecessary, but whatever, I'll just assume it's placeholder code.
return this._name;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment