Questions about JavaScript are generally OFF-TOPIC here. You might be able to find your answer at Stack Overflow.

Note that questions about web application development are off-topic at Web Apps. You may be able to find the answer to your question at Stack Overflow.

Questions about Google Apps Script, which is an implementation of JavaScript in Google Web applications, should instead be tagged .

While traditionally found in the browser, JavaScript (formally ECMA Script) can also run on the server, via frameworks like Node.js and Jaxer.

Note that despite the similar name, JavaScript is not to be confused with Java, which is another language entirely, albeit with similar syntax.