Yes, you can use JavaScript in your emails but it is not recommended. Most email programs will remove or disable any JavaScript code in your content.
How can I insert my own HTML code for my campaign?
Can I add an attachment without a URL in the body?