Javascript and the DOM

Posted 4 years, 1 month ago | Originally written on 12 Apr 2011

The DOM now makes sense! For the longest time I was completely perplexed as to the rationale behind Javascript.

In object-oriented design, the fundamental concept is that of a data structure referred to as a class from which objects ('classes at work') are instantiated. The class is the abstraction - most general case - from which the instances are the 'concrete' realisations. The beauty with objects is that, in addition to have descriptive properties, they can do things. These are referred to as their methods. In a general-purpose programming language, classes may either be standardised (as part of the language) or user-defined hence the reference to the language's general-purposefulness. In Javascript there is one main object - the document.

DOM describes the complete set of attributes of the page that may be modified before, during or after the page is availed to the user. Javascript is designed around the document and therefore speaks documese. Javascript inbuilt functions complement the document. It is easily appreciable, therefore, why a clear understanding on the document's structure will go a long way in aiding a web developer to write Javascript code.