DEV Community

Shoyab khan
Shoyab khan

Posted on

Day 1 of 30 of JavaScript

Hey everyone! 😊 I hope you're all doing well. In this '30 Days of JavaScript' series, we'll dive into JavaScript from the basics to advanced concepts. I'll be sharing my knowledge in a straightforward and easy-to-understand manner. Let's get started!

First off, let's clear up a common confusion: Java and JavaScript are completely different languages. Now that we've got that sorted, let's move on.

Image description

JavaScript is a crucial and popular programming language with numerous applications, ranging from web development to blockchain. It's also quite easy to learn.

JavaScript was created by Brendan Eich in 1995.

What is JavaScript?

JavaScript is a cross-platform, object-oriented programming language that developers use to make web pages interactive. Think of a website as a house: HTML provides the structure like walls and doors, CSS adds style with paint and decor, and JavaScript is like the electricity that brings everything to life. In other words, JavaScript transforms static web pages into dynamic, interactive experiences for users.

Features of JavaScript

  • JavaScript is a structured programming language.
  • It is lightweight and interpreted.
  • It is case-sensitive.
  • JavaScript uses prototypes instead of classes for inheritance.
  • It is compatible with various operating systems, including Windows and macOS.

Applications of JavaScript

JavaScript has a wide range of applications:

  • Web Development: JS enables developers to create dynamic and interactive web pages. Some well-known websites built with JavaScript include Google, YouTube, and Facebook.
  • Web Applications: Many JavaScript frameworks are used to build robust web applications. For example, Netflix and PayPal were developed using the AngularJS framework.
  • Server Applications: JavaScript can be used to write server-side software with Node.js, an open-source runtime environment. Top companies like Walmart, PayPal, Uber, and GoDaddy use Node.js for their server infrastructure.
  • Web Servers: Node.js allows developers to create web servers using JavaScript.

But that's not allβ€”JavaScript has many more applications.

How to Use JavaScript in a Webpage

There are two main ways to include JavaScript in a webpage:

  1. The <script> Tag: In HTML, JavaScript code is placed between <script> and </script> tags. For example:
   <script>
   console.log("Hello world");
   </script>
Enter fullscreen mode Exit fullscreen mode

Scripts can be placed in the <body> or <head> section of an HTML page, but it's generally better to place them at the end of the <body> to avoid slowing down the page load time.

  1. External JavaScript: It's often better to keep JavaScript in a separate file for simplicity and better code organization. This can be done like so:
   <script src="script.js"></script>
Enter fullscreen mode Exit fullscreen mode

The script will behave as if it were located exactly where the <script> tag is placed.

That's it for this tutorial. In the next post, we'll explore how to display outputs in JavaScript. Stay tuned and don't forget to follow me!

Top comments (0)