What is Javascript ?

Praveen SinghPraveen Singh
6 min read

JavaScript is like the superhero of the web world – it's high-level, so it doesn’t make you mess with the boring, nitty-gritty details of the computer. It’s dynamic, meaning it can change its mind on the fly (kind of like that friend who can't decide where to eat but keeps you entertained anyway). And guess what? It’s interpreted – no need for a long, drawn-out prep session before it shows off its moves; it just gets straight to the action.

This tech beast works its magic inside your browser, adding that flair of interactivity you can’t live without. And just like Batman has his Batmobile, JavaScript is one of the three pillars of the web, alongside HTML (the structure) and CSS (the stylish looks). Together, they form the dynamic trio that makes the web a fun, interactive playground. Without JavaScript, the web would just be a static page of text, like an ancient scroll. And we’re all about keeping things fresh and exciting!

Let's break down the statement and explain each part with examples:

1. High-Level Language

JavaScript is considered a high-level programming language because it is abstracted from the machine code. This means developers don't need to worry about low-level operations (like memory management), and they can focus more on writing the logic for their programs.

Example: In a low-level language like assembly, you'd have to manage memory directly. But in JavaScript, you can simply use variables to store data without worrying about how memory is allocated.

let message = "Hello, World!";

Here, you are creating a variable message to store a string. JavaScript automatically manages the underlying memory for you.

2. Dynamic Language

JavaScript is dynamic because its behavior can change during runtime. This means you don't need to specify the types of variables explicitly, and types can be reassigned as the program runs.

Example: You can change the type of a variable in JavaScript at any time.

let number = 10; // Number
console.log(number); // Output: 10

number = "Now I'm a string!"; // Reassigned to a string
console.log(number); // Output: Now I'm a string!

In the above code, the number variable was initially a number and later reassigned to a string. This dynamic behavior allows flexibility in the code.

3. Interpreted Language

JavaScript is interpreted, meaning that code is executed line-by-line at runtime by a JavaScript engine (like the one built into web browsers). This is different from compiled languages, where the code must be compiled into machine code before running.

Example: When you write JavaScript in a webpage, it is executed directly by the browser. The browser does not need to compile it before running the code.

Here’s a simple HTML page with embedded JavaScript that runs directly in the browser:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JavaScript Example</title>
</head>
<body>
    <h1>JavaScript Example</h1>
    <button onclick="alert('Hello, JavaScript!')">Click Me</button>

    <script>
        console.log("This code is interpreted by the browser.");
    </script>
</body>
</html>

When you click the button, JavaScript executes and shows an alert: "Hello, JavaScript!". The script inside <script> is interpreted by the browser's JavaScript engine.

4. Prototype-based Object Orientation

JavaScript’s take on object-oriented programming is a little rebellious – instead of classes, it goes with prototypes. Think of it like a family tree, where objects inherit cool powers (properties and methods) from other objects. It’s like the superhero version of inheritance, except it’s not all about your parents – it’s more like a wild, free-flowing family of objects passing down cool traits!

5. Event-Driven

JavaScript is all about reacting to things like a drama queen at a party – it’s event-driven, meaning it’s always listening for what happens. Did you click a button? Did you type on the keyboard? Boom, JavaScript's got an action ready! It's like your web page’s personal assistant, always on standby for the next move.

6. Asynchronous Programming

JavaScript doesn’t like to wait around. It’s into asynchronous programming – which means it can multitask like a pro. Want to fetch data from a server while still keeping the page running smoothly? No problem! JavaScript’s callbacks, Promises, and Async/Await let it do a bunch of things at once, like a juggler tossing around tasks without missing a beat.

4. The Holy Trinity of the Web

JavaScript is one of the three amigos that make the web awesome, hanging out with HTML and CSS to get the job done.

  • HTML: Lays the foundation – think of it like the skeleton of your web page (headings, paragraphs, buttons, you name it).

  • CSS: The fashionista – it gives the web page its style, adding colors, fonts, and making everything look on point.

  • JavaScript: The life of the party – it’s what makes things move and groove, from button clicks to popping up validation messages and making your page feel alive!

Where is JavaScript Used?

1. Web Development

JavaScript is the wizard behind the curtain of the web – it turns boring pages into interactive, jaw-dropping experiences. Want to make a button do a cool dance? Or validate a form with a click? JavaScript’s got your back. With super-powered frameworks like React, Vue, and Angular, it’s like the Swiss Army knife for building web apps.

2. Server-Side Development

JavaScript isn’t just a web browser party animal; thanks to Node.js, it’s now slinging code on the server-side too. JavaScript has gone full-on full-stack, creating lightning-fast apps that can handle a bunch of requests without breaking a sweat. It’s like the Clark Kent of programming languages – doing everything with ease!

3. Mobile Apps

Want to build an app for both iOS and Android? JavaScript’s got you covered! With React Native and Ionic, you can create cross-platform apps without needing to clone yourself. It’s like a cheat code for mobile development – build once, deploy everywhere!

4. Game Development

Who said JavaScript doesn’t play games? It’s the behind-the-scenes hero in browser-based games and interactive content, using frameworks like Phaser and Babylon.js. It’s the player 1 of the game dev world, making your favorite web-based games come to life.

5. Browser Extensions

JavaScript is also the secret sauce for browser extensions. Want to make your browser smarter, faster, or just a bit more fun? JavaScript allows devs to create those handy little tools that make browsing an adventure. It's like giving your browser a cool upgrade – it's practically like giving it superpowers!

Conclusion

And there you have it, folks! JavaScript is the rockstar of the web, adding that interactive magic to websites, powering mobile apps, and even being the unsung hero behind games and browser extensions. From high-level wizardry to event-driven fun, this language is as dynamic as your favorite action movie. Without it, the web would be as dull as a blank page – no cool buttons, no snazzy animations, just a whole lot of text.

But don't worry, this was just the appetizer! Get ready to dive deeper into the JavaScript jungle in the next session where we’ll explore the JavaScript basics that’ll make you a coding legend! So, buckle up and keep those coding caps on! 😎💻🎉

1
Subscribe to my newsletter

Read articles from Praveen Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Praveen Singh
Praveen Singh