I've built a Component-Entity-System library in JavaScript a while back, and the code is quite similar. You can check it out at https://github.com/qiao/ces.js