Skip to content

Instantly share code, notes, and snippets.

@fillano fillano/mod1.js
Created Jun 8, 2017

What would you like to do?
create class with readonly attribute.
const t = Symbol('ttt');
module.exports = class {
constructor(name) {
this[t] = name;
get name() {
return this[t];
sayHello() {
console.log(`Hello ${}`);
const Greeting = require('./mod1');
let m1 = new Greeting('Fillano');
m1.sayHello();//show 'Hello Fillano'
console.log(;//show 'Fillano' = 'Allen';
console.log(;//still show 'Fillano'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.