devxlogo

JavaScript QuickStart: What Is JavaScript?

JavaScript QuickStart: What Is JavaScript?

irst, a formal description:

JavaScript is an object-oriented scripting language that lets you build interactions between page content, the state of the browser, and the actions of the reader.

In other words, JavaScript is a language that lets you make your pages interact with your readers and respond to what they do.

It is a programming language that can make your pages feel more dynamic and give feedback to your user. This is a good argument for learning and incorporating it into your web techniques basket.

It is a programming language that also has a learning curve in order for you to use it well. But don’t let this scare you away from it?if you aren’t a programmer, you can start out by learning a few basic concepts and then adapt existing JavaScript scripts for your needs.

If you don’t want to tackle JavaScript, that’s OK too. You can still make attractive pages that your readers will like, using standard HTML. Don’t let the “flavor of the month” mentality convince you that only programmers or big budget outfits can have a Web page. But take a look through this section?you might surprise yourself by knowing more about scripting than you think.

JavaScript vs. Java
The number one area of confusion about JavaScript is thinking that it is the thing same as Java.

No. Nope. Not the same.

They two are different creatures that share only an object philosophy and a similiar name.

  • Java is a compiled programming language, comparable to languages such C, C++, or Pascal.

    Everything from small applets (tiny programs) to entire shrink-wrapped applications are being created in Java. Many in the programming world predict that Java will eventually replace C and C++ as a language of choice for application development.

  • JavaScript is a scripting language, ideal for small programs used only from within Web browsers. A JavaScript script can’t run alone, without the browser, the way a Java program does.

    JScript is Microsoft’s implementation of JavaScript.

A Little History…
In typical Web fashion, the evolutionary process of JavaScript has taken a somewhat lumpy path. When JavaScript started out life at Netscape, it was called LiveScript and its goal was to allow dynamic (“live”) changes of Web pages and communication between the Web browser and plug-in applications … such as Java. Java was hot and marketable, so in late 1995 Netscape got permission from Sun, the creators of Java, to use the word “Java” and Livescript became the *catchier* JavaScript.

But along the way, JavaScript took on a life of its own. It was easier for non-programmers to learn than Java. It could add a lot of interactivity with little overhead. Like HTML code, JavaScript is contained within the HTML text file, so it can be easily added and modified. It became hot itself. And so now there’s a move afoot to standardize JavaScript.

More Than You Might Want to Know, But…
Within the Web environment, the most common use of Java is to build applets, small programs that launch automatically from within a Web page. When the Web page loads, these applets are launched and begin to run on your local computer. While the applet runs, your browser sits quietly by.

On the plus side, running a Java applet doesn’t consume server time. It makes it possible for small, self-contained programs to be delivered via the Web, but run locally on individual computers. However, downloading Java applets has some people concerned about security; in corporate environments, Information Systems departments sometimes set up procedures to screen out external Java applets and prevent them from being downloaded. These IS managers fear (rightly or wrongly) that the applet could infect the system or be, in some way, a threat to the network.

JavaScript, on the other hand, is attractive to Web developers because it is a scripting language rather than a self-executing program. The code is typically placed directly in the Web page?in fact, it requires a Web browser in order to run and it is designed to be fully-integrated with the browser. Because the JavaScript is physically located within the Web page, firewalls can’t screen it out (although individual browsers can be configured to turn off JavaScript).

What Can JavaScript Do for Me?
With just a few JavaScript snippets you can transform a static page into something extraordinary. But don’t just let us tell you?click on the text below to see four different examples of a script in action.

JavaScript can:

JavaScript scripts can also do “invisible” but critical functions like analyzing which browser a reader is using and displaying the correct version of the page for that browser type.

Look at a Script
So how complicated are JavaScript scripts? And how do you recognize one in an HTML text page?

Scripts can range from the very basic to the very complex, depending on what they do and how they were written. It’s easy to spot a JavaScript script in an HTML source file. Just look for the tags:

.

The script appears between them. Most often, the script will be at the very beginning of the HTML text file.

In most cases, it is good style to place the scripts first. In other cases, it is essential that the script is first. For example, if you are using a script to see what type of browser the reader is using and to deliver the appropriate page for that browser type, the detection script must be the first thing in the file or the script won’t work correctly.

This is an example of a script. Click on it to see how it acts. The example appears in the window at the top of the screen:


This is a very simple script:

  • The first line tells the document to write a line of text. The text to write is the words “This line of text” followed by the HTML break tag.

  • The second line tells the document to write a second line of text. The text is “Is generated by a script.”

    That’s all the script does. It can be as simple as that.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist