Usually you do this on the wallet service you are using. They provide server-to-server notification callbacks when the address receives transactions. Then you parse this transaction and let your on server to notify JavaScript clients.
EDIT: SoChain offers no-authentication, WebSockets, API to monitor Bitcoin addresses in real-time. You can use this on cliet-side JavaScript directly:
https://chain.so/api#realtime-balance-updates
I don't know if any pure client-side JavaScript APIs exist with notification feature - you always need to set up webhooks to some server, or be directly connected to bitcoind.
Also there is the issue of confirmation level - when you consider the transaction to be received, how many confirmations you demand for it. You'll usually end up getting several notifications per each new confirmation.
I have done this in my open source project Liberty Music Store using blockchain.info.
For inspiration, see the relevant blockchain.info webhook code which then forwards this information to JavaScript through Redis pub-sub listener pattern (though in this case it does using HTTP long poll instead of WebSockets for Android 2.3 compatibility):
https://github.com/miohtama/LibertyMusicStore/blob/master/tatianastore/blockchain.py#L110
https://github.com/miohtama/LibertyMusicStore/blob/master/tatianastore/static/main.js#L102
https://github.com/miohtama/LibertyMusicStore/blob/master/tatianastore/signals.py#L28
https://github.com/miohtama/LibertyMusicStore/blob/master/tatianastore/storefront.py#L253