Any protection that is implemented in user-level can be relatively easy defeated. Most often is used so called "obfuscation". It can be time consuming to deobfuscate such script if to do it by hand. However, there are several tools that automates this process, example - https://addons.mozilla.org/en-US/firefox/addon/javascript-deobfuscator/ Best solution is to implement protection in interpreter itself, at bytecode level, like Zend Guardian for PHP (even it is bypassable). I suppose, for JavaScript this cannot be done due to many JS engines implementations, parser engines differences, etc. Additionally, it would require loading modules that have to be distributed by protection vendor. This is hard and not transparent process.
I have seen interesting protection in malware, in that case JavaScript code was protected with RSA and used key from the server. But again, it is headache for developer to support such process. Probably for malware writers it was worth to protect their exploits against AV's, lurking users, researchers.
Additionally, you can read related topic here: https://stackoverflow.com/questions/964652/javascript-protection