JavaScript

Updated: 01/31/2019 by Computer Hope

JavaScript or JS logoDeveloped by Brendan Eich and originally known as LiveScript, the programming language JavaScript was renamed in 1995. JavaScript is an interpreted client-side scripting language that allows a web designer the ability to insert code into their web page. JavaScript is commonly placed into an HTML or ASP file and runs directly from the web page. It is utilized to perform tasks such as printing the time and date, create a calendar, or other tasks that are not possible through plain HTML.

What is required to run JavaScript?

JavaScript only requires an Internet browser with JavaScript enabled. All browsers by default will have JavaScript enabled.

Is JavaScript safe?

Because JavaScript is downloaded from an unknown origin and executed on your computer, JavaScript could have the potential of being a virus or doing other malicious things to your computer. To address this issue, Sun implemented tight security features from the earlier stages of development. These features include:

  • When the browser runs the JavaScript, it is isolated to the browser process. Browsers like Chrome and Edge will sandbox JavaScript as an additional security measure.
  • JavaScript cannot read from or write to the hard drive or another storage device connected to the computer.

However, even with the above safety measures, anything connected to the Internet is never 100% safe and it is possible for a computer to be compromised using JavaScript. To help possible security breaches JavaScript can be disabled. However, most sites today require JavaScript to be fully operational. Alternatively, you can make sure to always make sure you're running the latest version of your browser to help keep safe. There are also browser add-ons that can be installed to help control JavaScript or its features on websites.

Are Java and JavaScript the same thing?

No. Java and JavaScript are two different computer programming languages with a few similarities. If you want to learn one of the languages and want to develop features for the Internet and websites, you should learn JavaScript. If you want to develop applications (e.g., a game that runs on a computer or smartphone without the need of a browser) you should learn Java. See our Java definition for further information about Java.

Hello, World! in JavaScript

<SCRIPT LANGUAGE="JavaScript">
<! -- Hide from old browsers
document.write('Hello World!');
// Stop hide -->
</SCRIPT>

Tip: With HTML5 you no longer need to specify the language attribute.

Live example of JavaScript

Below is an example of a JavaScript implemented into this page that will print the current time and date. Like all JavaScript files, the user's Internet browser must be capable of viewing JavaScript and the execution of JavaScript must be enabled. If JavaScript is not enabled, the time and date will not be visible.

Tip: See the JavaScript time and date source code to use these JavaScript features in a web page.

Although JavaScript files are often embedded into the HTML file, users can also save their JavaScript code in an external file. This file often ends with a .js file extension.

List of JavaScript example scripts

Below is a list of JavaScript examples we've collected and created that can help demonstrate different abilities of JavaScript and include into your website.

Bookmarklet, Grasshopper, Java, JavaScriptCore, JavaScript Hijacking, jQuery, JScript, LiveScript, Programming terms, Server-side scripting, VBScript, Web design terms