Ported to Javascript
Updated documentation for JavaScript.