[JavaScript]
[Previous page] [Section contents page] [Next page]
Overview: Components

On the previous page, we saw that there are various components that make up a JavaScript. We'll explore these components in more detail in the pages that follow, but for now it will help to have overview of what they are and what they do. The major components are as follows:

Keywords Variables Operators
Control Structures Functions Objects
Properties Methods Comments

Keywords
"Words" that are reserved for special use by the JavaScript language, such as "var" (variable)
Variables
Defined entities whose values can be set and modified; unlike most program languages, JavaScript does not have explicit data types (such as integer or boolean) -- it does, however, have implicit data types that are defined by the values that are assigned to variables.
The implicit data types are:
  • integer
  • floating point
  • boolean
  • "nonatomic" types, such as objects and functions
  • string
  • null
Operators
Operators are something like verbs in sentences, combining or relating different pieces of data. The operators in JavaScript fall into four general categories:
  • computational (for addition, subtraction, etc.)
  • logical (for comparisons)
  • bitwise (these deal with the binary representations of data)
  • assignment (for assigning values to variables)
Control Structures
Control structures make scripts do things by making decisions or automating repetitive processes.
Functions
A function is really a special kind of object, a reusable set of statements that can be called to operate when needed, much like a subroutine in older programming languages.
Objects
Objects are data structures that include bits of data themselves, along with two kinds of information related to the data: properties and methods. There are three kinds of objects associated with JavaScript:
  • built-in objects (these are specific to the JavaScript language, and have nothing specifically to do with the Web)
  • browser objects (various objects associated with the user's web browser)
  • document objects (various objects associated with HTML documents)
Properties
Properties are information types associated with a particular object, much as we think of physical objects as having properties like a name, color, and so forth.
Methods
Methods are certain kinds of properties that perform some function; in the script on the previous page, for instance, we saw the write method for the document, which writes some text (that may contain HTML code) into it.
Comments
Like comments in HTML and other coding languages, JavaScript comments do not affect the operation of the script in any way, but rather serve to explain (or remind you) what various parts of the script code do. Notice that there are two forms for comments:
  • /* this is a "C" style comment, which can span multiple lines */
  • // this is a comment from the "//" to the end of the line
[Previous page] [Section contents page] [Next page]