Browse DevX
Sign up for e-mail newsletters from DevX


JavaScript QuickStart: Elements of JavaScript

JavaScript is cropping up everywhere and if you want to learn to use it, you'll need to understand these essential elements.


ike any other language—be it English, Japanese, or C—JavaScript has some basic elements with which you work. In JavaScript these include: objects, variables, arrays, operators, events, event handlers, statements, and functions.

Don't worry if you aren't familiar with these terms. They make common sense once you see what they are.

Objects are the most basic building blocks of JavaScript. They are the elements upon which the whole object-oriented philosophy is built. They are the elements that interact with each other and with the reader based on a set of pre-defined rules. JavaScript objects include items such as the browser window and the HTML document.

Each object has a set of characteristics, called properties, and a set of things it can do, called methods.

For example:

  • One of the document object's properties is "bgColor". You can give use JavaScript to se the background color of an HTML document.

  • One of the document objects's methods is "write". You can use JavaScript to write text in an HTML document.

Each type of object is a template. You can create instances, or copies, of an object, assign the new instances different properties, and work with the instances in your scripts.

When you see an object used in a script, it is usually written like this, with the object type followed by one of its methods or properties, followed by that method's or properties attributes. For example:


sets the document's background color property to white.

For example:

document.write(Welcome dear reader, to my Web-abode);

uses the document.write method to write the phrase "Welcome dear reader, to my Web-abode" into the HTML document.

Thanks for your registration, follow us on our social networks to keep up-to-date