JSFiddle - React, Tailwind, and code Playground
HTML
<div id="out"></div>
JavaScript
function l(s) {
$('#out').append($('<div />', {
html: s.toString()
}));
}
function BlahObj() {
this.users = {};
}
BlahObj.prototype = {
userGet: function(id) {
if (this.users[id] !== undefined) {
l(this.users[id]);
}
},
userAdd: function(id, name) {
if (this.users[id] === undefined) {
this.users[id] = name;
}
},
user: {
get: function(id) {
if (this.users[id] !== undefined) {
l(this.users[id]);
}
}
}
}
var test = new BlahObj();
test.userAdd(1, 'User A');
test.userAdd(2, 'User B');
test.userAdd(3, 'User C');
test.userGet(2);
try {
test.user.get(1);
} catch (e) {
l(e);
}