JavaScript is a programming language. JavaScript programs are embeded inside HTML code and executed when the page is viewed. You can use JavaScript to bring HTML to life! JavaScript can change the contents of a web page after it has been rendered by the browser and can perform actions based on user iput. Unlike HTML, JavaScript is case sensative.
JavaScript compared to Java| JavaScript | Java |
|---|---|
| Interpreted (not compiled) by client. | Compiled bytecodes downloaded from server, executed on client. |
| Object-oriented. No distinction between types of objects. Inheritance is through the prototype mechanism, and properties and methods can be added to any object dynamically. | Class-based. Objects are divided into classes and instances with all inheritance through the class hierarchy. Classes and instances cannot have properties or methods added dynamically. |
| Code integrated with, and embedded in, HTML. | Applets distinct from HTML (accessed from HTML pages). |
| Variable data types not declared (dynamic typing). | Variable data types must be declared (static typing). |
| Cannot automatically write to hard disk. | Cannot automatically write to hard disk. |
In addition to being an interpreted scripting language, JavaScript is an object oriented programming language. An object is a programming code and data that can be treated as an individual unit or component. Individual lines in a prigramming language are called statements. Groups of related statements associated with an object are called methods. JavaScript treats many things as objects. One of the most commonly used objects in JavaScript programming is the Document object. the Document Object represents the content of a browser's window. Any text, graphics, or other information displayed in a Web page is part of the Document object.