It may be shocking news, but JavaScript is a very powerful object-based (or prototype-based, whatever you wish to call it) language. Yes, JavaScript is a powerful language, not just something that's handy for image rollovers and other corny, flashy effects. However, very few people who have used JavaScript realize its capabilities. If you're one of these people, this tutorial is aimed at you.

     First of all, JavaScript is not a full-blown OOP (Object-Oriented Programming) language, such as Java, but it is an object-based language. So, why should you use objects? Not only do they help you better understand how JavaScript works, but in large scripts, you can create self-contained JavaScript objects, rather than the procedural code you may be using now. This also allows you to reuse code more often.

JavaScript's Primitive Data Types

JavaScript has five primitive data types:

Throughout this tutorial, we'll use the latter three extensively.

A Boolean is a logical entity that consists of either a true or a false value. An example of one is:

var BooleanValue = true;

A Number is a set of numerical digits that represent a number. Through this tutorial, we'll only use base-10 numbers. An example:

var NumericalValue = 354;

A String is a set of zero or more characters. An example:

var StringValue = "This is a String";

Typeof

A less-known operator in JavaScript is the typeof operator. It tells you what type of data you're dealing with. Makes sense, huh? Let's look at some examples:

var BooleanValue = true;
var NumericalValue = 354;
var StringValue = "This is a String";
alert(typeof BooleanValue); // displays "boolean"
alert(typeof NumericalValue); // displays "number"
alert(typeof StringValue); // displays "string"