What Is JavaScript?

Learn about this Programming Language

Degui Adil / EyeEm / Getty Images

What Exactly Is JavaScript?

JavaScript is a programming language used to make web pages interactive. It runs on your visitor's computer and doesn't require constant downloads from your website. JavaScript is often used to create polls and quizzes.

Are JavaScript and Java the Same?

No, they are two completely different computer languages. Only their names are similar. If you want to learn about Java instead, we have a whole other resource section on Java.

What Do I Need to Run JavaScript?

JavaScript support is built right into all the major web browsers, including Internet Explorer, Firefox and Safari. Provided that the visitors to your site are using web browsers that support JavaScript (most do) and have JavaScript enabled (it is by default), then your JavaScript will run when they visit the page.

Do I Need to Learn Javascript to Be Able to Use It?

No. There are plenty of pre-written JavaScripts that people have made available for you to plug straight into your web page. All you need to know to be able to use such scripts is how to paste the supplied code into the required places in your web page.

What Do I Need to Write JavaScript?

JavaScript is an interpreted language, so no special program is required to create usable code. Any plain text editor such as Notepad (one of the Accessories that comes in Windows) is quite satisfactory for being able to write JavaScript.

That said, an editor that colorizes the code to make it easier to see what is what makes it easier to find your mistakes. 

Can I Use HTML Instead of JavaScript?

No. HTML and JavaScript are two completely different things. HTML is a markup language designed for defining static web page content. JavaScript is a programming language designed for performing dynamic tasks.

Sometimes the distinction is confusing because JavaScript code can go in the same file as HTML. (More on that in a minute.)

Can I Use PHP or Some Other Server-Side Language Instead of JavaScript?

Perhaps. It depends where the code needs to run. If it can run before the page loads, you can use a server-side language. If it has to run after the page has loaded, then you must use JavaScript, as this is the only scripting language supported by all web browsers that support client-side scripting.

Does the Javascript Go in the Same File as the HTML?:

It can, but your scripts will be more easily reused on multiple pages of your site if you place them in separate files. (Using a .JS extension helps identify them as Javascript.) You then just link the JavaScript to your HTML by inserting a <script> tag. The same JavaScript can then be added to several pages just by adding the appropriate tag into each of the pages to set up the link.