Page 178 - Web_Application_v2.0_C12_Fb
P. 178
JAVASCRIPT PART 2 2
Learning Outcomes
• Basic Structure of a JavaScript Program • The Write() and Writeln() Methods
• Interacting with Html • JavaScript Data Types
• Statements in JavaScript • Functions in JavaScript
• Object-Oriented Programming Principles • Objects in JavaScript
• Strings in JavaScript • String Properties and Methods
• Arrays in JavaScript • Array Properties and Methods
• Math Method • JavaScript Events
JavaScript was created in 1995 by Brendan Eich, a programmer and computer scientist at Netscape
Communications Corporation.
It is an interpreted language, meaning it doesn’t need to be compiled into machine code. Instead, an
interpreter reads and executes the code line by line. If an error is encountered during execution, the program
stops immediately at that point. JavaScript was first used in web browsers to enable websites to react to user
actions, control the browser, send and receive data, and change their content.
JavaScript makes websites think and act, making them more interactive and dynamic. It's used for checking
and changing data, and doing calculations. The good thing is it can be used on both the website's server and
the user's computer.
JavaScript works closely with HTML code, but it's handled separately by the browser. In JavaScript, the code is
typically interpreted, not compiled beforehand like languages such as C++ or Java.
JavaScript is added to HTML using the <script>...</script> tags and can be placed in three different locations
within an HTML document:
1. In the Body: The script runs as the page loads, and the output appears directly in the HTML content.
2. In the Head (as a function): Scripts are written as functions, which can be called from anywhere else in
the page.
3. As an External File: JavaScript code can be written in a separate file with a .js extension. This file is linked
to the HTML document using the <script src="filename.js"> tag.
176 Touchpad Web Applications (Ver. 2.0)-XII

