Skip to main content

Command Palette

Search for a command to run...

Learn About Javascript(JS)

Updated
4 min read
Learn About Javascript(JS)

What is Javascript?

JavaScript (JS) stands as a versatile and dynamic programming language, distinguished by its lightweight, interpreted (or just-in-time compiled) nature and its support for first-class functions. Although its primary association lies with enhancing web page interactivity, its application extends far beyond the browser, finding use in diverse environments such as Node.js, Apache CouchDB, and Adobe Acrobat. Characterized as a prototype-based, multi-paradigm, single-threaded language, JavaScript seamlessly accommodates object-oriented, imperative, and declarative programming styles, including functional programming, making it a powerful tool for a wide range of development tasks.

History of Javascript

  • 1995: The Birth:

    • JavaScript was created by Brendan Eich at Netscape Communications.

    • It was initially developed under the name "Mocha," then "LiveScript," and finally named "JavaScript."

    • Its initial purpose was to add interactivity to web pages within the Netscape Navigator browser.

  • Early Years:

    • Early versions of JavaScript had limitations and faced criticism.

    • However, its role in enabling client-side scripting made it indispensable for web development.

  • Standardization: ECMAScript:

    • To standardize JavaScript, Netscape submitted it to ECMA International, leading to the creation of the ECMAScript standard in 1997.

    • This standardization helped ensure cross-browser compatibility.

  • Evolution and Modern JavaScript:

    • Over the years, ECMAScript has undergone significant revisions, with major updates like ECMAScript 5 (ES5) and ECMAScript 6 (ES6/ES2015) introducing crucial features.

    • The rise of Node.js allowed JavaScript to be used for server-side development, expanding its reach beyond the browser.

    • Javascript continues to evolve with yearly updates to the ECMAScript standard.

  • Present Day:

    • JavaScript is now one of the most popular programming languages in the world.

    • It's used for front-end and back-end web development, mobile app development, and more.

Versions of Javascript

1.The Foundations (ES1-ES3):

It all started in 1997 with ECMAScript 1 (ES1), the first official edition. ES2 (1998) was largely editorial, but ES3 (1999) brought some serious muscle, introducing core features like regular expressions, / try/catch error handling, switch statements, and the do-while loop. These laid the groundwork for the dynamic web we know today.

2.The Lost Version (ES4):

Interestingly, ECMAScript 4 (ES4) was an ambitious project that ultimately never saw the light of day. It aimed to introduce significant changes, but disagreements and complexities led to its abandonment.

3.The Renaissance (ES5):

Fast forward to 2009, and ECMAScript 5 (ES5) marked a turning point. It brought much-needed standardization and crucial features like "strict mode" for cleaner code, built-in JSON support, string manipulation with String.trim(), array checks with Array.isArray(), and powerful array iteration methods. Plus, who can forget the convenience of trailing commas in object literals?

4.The Modern Era (ES6/ES2015 and Beyond):

ECMAScript 2015 (ES6) was a game-changer! It introduced modern JavaScript as we know it, with let and const for block-scoped variables, default parameter values, and essential array methods like Array.find() and Array.findIndex().

Since then, ECMAScript has adopted a yearly release cycle, bringing incremental but impactful updates:

  • ES2016 (ES7) added the exponential operator (**) and Array.includes().

  • ES2017 (ES8) brought us string padding, Object.entries() and Object.values(), async functions, and more.

  • ES2018 (ES9) introduced rest/spread properties, asynchronous iteration, and Promise.finally().

  • ES2019 (ES10) gave us methods like String.trimStart() and String.trimEnd(), Array.flat(), and Object.fromEntries.

  • ES2020 (ES11) delivered the incredibly useful Nullish Coalescing Operator (??).

Adding JavaScript into an HTML Document

  • The <script> tag can be placed in the <head>section of your HTML or in the <body> section, depending on when you want the JavaScript to load.

  • You can add JavaScript code in an HTML document by employing the dedicated HTML tag <script> that wraps around JavaScript code.

Let’s consider the following blank HTML document with a browser title of Example of adding the JS in HTML:


Normal HTML file without adding the JS File.

index.html

<!DOCTYPE html>
<html lang="en-US">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Example of adding the JS in HTML</title>
</head>

<body>
</body>

</html>

Example of:

The <script> tag can be placed in the <head>section of your HTML or in the <body> section, depending on when you want the JavaScript to load.

index.html

<!DOCTYPE html>
<html lang="en-US">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>adding the JS file externally </title>

    <script src="script.js"></script>

</head>

<body>
</body>

</html>

script.js

//Javascript code

Example of:

Adding JavaScript code in an HTML document by employing the dedicated HTML tag <script> that wraps around JavaScript code.

<!DOCTYPE html>
<html lang="en-US">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>adding the JS file inside the HTML file</title>

    <script>
                        //JS Code              
    </script>    

</head>

<body>
</body>

</html>