I haven't used JavaScript specifically, but I've integrated Groovy into my application framework to provide a domain specific language (DSL). I've created functions and classes that hook into my application.
The user is allowed to script common operations within the application (macros) as well as implement lightweight processing to avoid the much heavier code-compiler-jar-deploy solution. If the user has an idea for a plugin to my processing framework they can prototype via Groovy in realtime and move back to Java (maybe even native) when there is time (or when speed is needed). Keep in mind that scripting is typically orders of magnitude slower than Java/C#/C/C++