https://nemisj.com/why-getterssetters-is-a-bad-idea-in-javascript/
Last active
March 17, 2017 23:23
-
-
Save Happy-Ferret/7bf0db886889704b118a06f7b17d7e34 to your computer and use it in GitHub Desktop.
Javascript library example
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
class fooClass { | |
constructor(options) { | |
this.label = options.label | |
this.bar() | |
} | |
bar() { | |
console.log(this.label) | |
} | |
} | |
module.exports = fooClass; |
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
const fooClass = require ("./fooClass") | |
var TEST = new fooClass({label:"TEST"}) | |
TEST.label = "TEST2017" | |
TEST.bar() | |
// RESULT: | |
// TEST | |
// Test2017 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment