Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
function _Emitter (name) {
  this.callers = {};
}
  _Emitter.prototype.add = function () {
    this.callers[this.name] = true;
  };
  _Emitter.prototype.log = function () {
    console.log(JSON.stringify(this.callers));
  };
// inherited
  
function Emitter (name) {
  this.name = name;
}
Emitter.prototype = new _Emitter();
// tests
  
var common = new Emitter(),
    foo = new Emitter('foo'),
    bar = new Emitter('bar');
foo.add();
bar.add();
common.log();
// 
// Recource.on('update', '087td08d7t0d78td073y3y893y', function () {});
// 
// Recource.on('update', 'any', function () {});
// 
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
jgermadepro
0viewers