Refactorized js impl. and reviewed documentation.

Refactorized javascript implementation due to be real javascript
implementation instead of wrong "class" oriented language imitation.