Javascript and its History and how it works.

Elaph Hilful
3 min readDec 12, 2021

--

What is Javascript?

Javascript is the most popularly used scripting language over the internet. Javascript is a client or browser-side scripting language. Along with that javascript is also an object-oriented programming language. It has data types, operators, some important objects, and functions or methods. If one is interested to work in the world of the web then learning javascript is a must for him or her.

A brief history of Javascript

Netscape assigned Brendan Eich to create an entirely new programming language and after working on it for quite some time he created JavaScript. Netscape implemented it on their web browser and named it Navigator 2.0. Initially created javascript was known as Mocha back then. In 1996 Mocha was renamed to LiveScript.Later LiveScript changed its name into what we now call javascript. The name javascript was given for a promotional purpose by Netscape and is considered a very nice marketing strategy to gain wider recognition and acceptance.JavaScript was brought to the ECMA standards group in 1996 to create an official standard for the language that everyone could follow. After that many versions of JavaScript were released. Among the most noteworthy ones in 2009, along with the ES standard 5, NodeJs was released. This allowed programmers to write full applications in JavaScript.NPM also known as Node Packet Manager was created for installing reusable bits of code in libraries. ES6 was released in 2015 and by then JavaScript had gained immense popularity and was one of the most in-demand programming languages. Today, applications of JavaScript can be seen in diverse fields like gaming, web development, server development, and robotics among others. Popular JavaScript libraries and frameworks like ReactJs and Angular have scaled tremendously in the past few years. Companies like Paypal, Netflix, Facebook, Google, Uber, and HBO use JavaScript and their frameworks in their products.

How JavaScript changes HTML?

There are many different methods in JavaScip and among the getElementByID() method is noteworthy.

In the below-presented example getElementById() method takes id=“test” for searching and is changed by “Hello Javascript”

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Example</title>
</head>
<body>

<h3>JavaScript Example</h3>
<p id="test">JavaScript can change contents in HTML</p>

<button type="button"
onclick="document.getElementById('test').innerHTML = 'Hello JavaScript!'">Click Here</button>

</body>
</html>

Other than that Javascript can change HTML attributes.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Example</title>
</head>
<body>

<h3>JavaScript Example</h3>

<button onclick="document.getElementById('test').type='text">Show Password</button><br><br>

<input id="test" type="password" value="123456"><br><br>

<button onclick="document.getElementById('test').type='password'">Hide Password</button>

</body>
</html>

JavaScript can change HTML style

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript Example</title>
</head>
<body>

<h3>JavaScript Example</h3>
<p id="test">Javascript can change HTML Style

<button type="button" onclick="document.getElementById('test').style.color='green'">Click Here!</button>

</body>
</html>

Where should you keep your JavaScript?

You should always place it within a HTML page in either <head> or <body> or in both places. JavaScript code is written within <script> tag.

<script>
document.getElementById("test").innerHTML = "My first JavaScript Code!!!";
</script>

Advantages of external JavaScript

  • You can easily differentiate between HTML and JavaScript.
  • It makes HTML and JavaScript more readable and it can easily be maintained
  • Cached JavaScript speeds up page loading rate.

--

--

Elaph Hilful

Every story I create creates me. I write to create myself.