add javascript example
Merged JDeuce's JS implementation