Introduction to JavaScript

Introduction

 
JavaScript is used along with HTML and CSS. It is one of the core technologies of the World Wide Web. Most powerful websites and browsers support JavaScript, like Google, Amazon, Facebook, etc.
 

History of JavaScript

 
In May 1995, Brendan Eich developed JavaScript while working with Netscape. JavaScript was created in just 10 days. The first name of JavaScript is “Mocha”, the name chosen by Marc Andreessen, the founder of Netscape.
 
The language is officially called Live Script, when it was first released in beta. Later the finalized name was JavaScript. JavaScript is often abbreviated as JS, and the JavaScript save file extension is .js
 

Uses of JavaScript

  • JavaScript can be used in multiple applications.
  • It can be used for Client-Side Validation, which is for creating web pages.
  • It is used to create web applications and server applications.
  • It can be used to show the error message on the popup menu on websites.
  • You can use JavaScript to create interactive web elements.

Advantages

  • Speed for the end-user
  • Increased interactivity
  • It is Open source and cross-platform
  • Easy to Learn

Disadvantage

  • Security issues
  • Code will not be hidden
  • JavaScript only supports single Inheritance

Create Your First JavaScript

 
In HTML, add JavaScript inside the<body> tag. JavaScript code must insert the “<script>” tag. JavaScript is case sensitive, see the example given below:
  1. <script>    
  2.     //you can write JavaScript Code    
  3. </script>     
 
Example
 
Use JavaScript to print the statement “Welcome to My Article” in a web browser.
  1. <!DOCTYPE html>    
  2. <html>    
  3. <head>    
  4.     <title>Java Script</title>    
  5. </head>    
  6. <body>    
  7.     <script>    
  8.         document.write("Welcome to My Article");    
  9.     </script>    
  10. </body>    
  11. </html>     
Output
 
 

Add Formatting Text in JavaScript

 
We can use HTML tags to format text in JavaScript. The text format tag <h1>to<h6>.
  1. <script>    
  2.     document.write("Welcome to My Article");    
  3. </script>     
Example
 
 
Output
 
 

Summary

 
In this article, we have seen a JavaScript introduction. I hope this article was useful to you.