Last active
June 25, 2023 09:08
-
-
Save joepie91/17cd52d8c8b71e376e06 to your computer and use it in GitHub Desktop.
Why ES6 > * (but not really)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Model = require('some-orm').Model | |
class User extends Model { | |
get name() { | |
return this._name | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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