added/fixed doc js sample code.
Merge pull request #3018 from sebv/doc-js

Added/fixed doc js sample code.