Introduction to JavaScript

Introduction

 
This article explains JavaScript, the history of JavaScript, JavaScript syntax and statements, the Document Object Model (DOM), JavaScript programs and Object-Oriented Programming.
 

History of JavaScript

 
JavaScript isn't Java. JavaScript is the programming language of the Web. JavaScript is one implementation of a specification known as ECMAScript. JavaScript was originally developed by Brendan Eich at Netscape sometime in 1995–1996 and later included in the Netscape 2.0 browser under the name of JavaScript.
 

JavaScript

 
JavaScript was the first web scripting language to be supported by browsers and the most popular Scripts. It can be included directly in HTML documents. JavaScript is almost as easy to learn as HTML. Programmers have developed many websites using simple Hypertext Markup Language (HTML). JavaScript provides client-side form validation and works instantly to validate the contents of a web form rather than making a round-trip to the server. Web browsers have consolidated around the specifications for content (HTML), presentation (CSS), and behavior (JavaScript).
 
Now, we refer to these three layers as structure, presentation, and behavior. It will look like the following layers.
 
 

JavaScript syntax and statements

 
It is an implementation of a standard. The following figure shows the ECMA-262 Edition 5 Specification: JavaScript syntax and statements
 
JavaScript syntax and statements
 
For more information about the JavaScript syntax and statements, see the Wikipedia and w3schools site:
 
JavaScript syntax or JavaScript If...Else Statements
 

Understand the DOM

 
The Document Object Model (DOM) provides a way to access and alter the contents of Hypertext Markup Language (HTML) documents. For the JavaScript programmer the Document Object Model (DOM) standard was developed by the World Wide Web Consortium (W3C). The W3C defines the DOM as “a platform- and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of documents.” The DOM represents HTML documents in a tree.
 
Understand the DOM
 
Simple HTML document
 
The following is a simple HTML document:
  1. <!DOCTYPE html>  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4.     <title>Hello World</title>  
  5. </head>  
  6. <body>  
  7.     <div>C# Corner<a href="http://www.c-sharpcorner.com/">W3</a></div>  
  8.     <div id="Content">Some Text</div>  
  9.     <div id="Footer">Link to the <a href="http://www.w3.org">W3</a></div>  
  10. </body>  
  11. </html> 
Now, shows the HTML from the figure when viewed in the tree structure of the DOM.
 
HTML elements can have attributes, such as the href attribute of the <A>element shown in the figure. You can both retrieve and set these attributes using the DOM. When working with the DOM, you should be aware of the distinction among retrieving elements, setting elements and items related to elements, and removing or deleting elements. The methods for working with DOM elements reflect this distinction.
 
For more information about the DOM, see the W3C site:
 
Document Object Model (DOM)
 
JavaScript program
 
A JavaScript program consists of statements and expressions formed from tokens of various categories, including keywords, literals, separators, operators, and identifiers placed together in an order that is meaningful to a JavaScript interpreter, that is contained in most web browsers.
  1. <!DOCTYPE html>  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4.     <title>JavaScript alert</title>  
  5.      <script type="text/javascript">  
  6.          alert("Hi. JavaScript Developer !");  
  7.     </script>  
  8. </head>  
  9. <body>     
  10. </body>  
  11. </html> 
Now, it will look like the following Scripts Executed:
 
JavaScript program
 

Object-Oriented programming

 
JavaScript has strong object-oriented programming. Object-oriented and what the main features of this programming style are. Here's a list of concepts that are most often used when talking about Object-Oriented Programming (OOP):
 
Object-Oriented programming


Similar Articles