For code: the best you can do is uglify and mangle it. This makes it harder to decompile and copy/paste. https://github.com/mishoo/UglifyJS
For data: (e.g. passwords, private keys), you have several possible attackers:
- User willingly attacking your app via OS tools and debugger
- Malware process attacking your app
1) If a user with root access is attacking your app, given enough time and know-how, they will win. The best defense is to limit the "surface area" they can attack. Encrypt your private data in memory, and deallocate/garbage collect it when your are done with the un-encrypted version. Javascript will not be awesome in helping you with this.
2) If a rogue process is attacking your app, then your is as safe as your operating system. If the malware is root it's the same as 1). Again, best option is to limit the surface area.
That said, browser extensions like password managers store secure data all the time, so it's not unheard of.
These links may be interesting to you: