The JavaScript language provides a great introduction to programming because its syntax is easy to learn, and the concepts you learn will carry over to other programming languages that you may learn in the future. In addition, the JavaScript language is modelled on the Java programming language, so it provides the perfect introduction to one of the most popular programming language of all time.
JavaScript is not, however, a full-featured programming language like Java. Programs written in the JavaScript language will be limited to working within the HTML environment, whereas other languages do not place such constraints on the developer.
Unlike other programming langagues that are compiled to run on a specific processor, the JavaScript language is an interpreted language. The source code for JavaScript is stored as plain text and embedded in the HTML document itself.
Object-based programming
To use JavaScript, you need to become familiar with the object-based syntax that the language employs. An object is a grouping of related properties (attributes, such as the colour of a document) and methods (action statements, such as the action to write text to the screen). To access a property or method in JavaScript, type the object name, followed by a dot (.), and then the property or method. The syntax would look like this:
object.property
For example, to access the background colour of a Web page, you would use the following syntax:
document.bgColor
Finally, a method must include opening and closing parentheses. Any additional information required by the method must be placed inside the parentheses:
object.method(arguments);
For example, to write the phrase, "Hello!" to a document, you would use the following syntax:
document.writeln("Hello!");