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 website popup menu.
  • You can use JavaScript to create interactive web elements.

Advantages of JavaScript

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

Disadvantages of JavaScript

  • 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:

<script>
  //you can write JavaScript Code
</script>

Example

Use JavaScript to print the statement “Welcome to My Article” in a web browser.

<!DOCTYPE html>
<html>
  <head>
    <title>Java Script</title>
  </head>
  <body>
    <script>
      document.write("Welcome to My Article");
    </script>
  </body>
</html>

Output

Add Formatting Text in JavaScript

We can use HTML tags to format text in JavaScript. The text format tag <h1>to<h6>.

Example

<script>
  document.write("<h1>Welcome to My Article</h1>");
</script>

Output

This output size is 32px to 40px (or 2em to 2.5em) because this is <h1>.

  • The font size of <h1> is 32px to 40px (or 2em to 2.5em).
  • The font size of <h2> is 24px to 32px (or 1.5em to 2em).
  • The font size of <h3> is 18px to 24px (or 1.125em to 1.5em).
  • The font size of <h4> is 16px to 20px (or 1em to 1.25em).
  • The font size of <h5> is 14px to 18px (or 0.875em to 1.125em).
  • The font size of <h6> is 12px to 16px (or 0.75em to 1em)

Summary

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