JavaScript Introduction

A summary of how to use JavaScript in your HTML files.

Play this article

JavaScript officially called ECMAScript is the most widely used scripting language on Earth (According to GitHub and stackOverflow). And it has the largest library ecosystem of any programming language. JavaScript is the core language of the web, and the only programming language that can run in all major web browsers. Today, JavaScript doesn't run only on browsers but servers and any computer that has a JavaScript engine.

How JS engines work First: They read the script. Second: They compile it to machine language that the computer can understand.

Uses of JS

🤓 Adding interactive behavior to web pages. JavaScript allows users to interact with web pages. 🤓 Creating web and mobile apps. Developers can use various JavaScript frameworks for developing and building web and mobile apps. 🤓 Building web servers and developing server applications. 🤓 Game development.

Resources for JS

📒 MDN JavaScript reference


📒 Dev Docs

📒 OverAPI JavaScript Cheat Sheet


⚔️ Hacker Rank

⚔️ Code Wars

⚔️ Sololearn

⚔️ Coding Game

⚔️ JavaScript 30

⚔️ Codility

Code editors To write code obviously you'll need somewhere to write. This is where code editors come in There're many code editors Code editors are divided into: IDEs(more powerful) and Simple editors(takes up less space)

Difference between An IDE and a simple editor A simple editor is just for writing/modifying text/code. With an IDE, you should do a lot more within that single program; running, debugging, version control Recommended IDEs VS code ( Mac, Linux, Windows) Webstorm ( Mac, Linux, Windows) Atom IDE ( Mac, Linux, Windows) Komodo Edit ( Mac, Linux, Windows) Spck Editor (Android)

Recommended Code Editors Spck Editor (Android) VS code ( Mac, Linux, Windows) Sublime Text ( Mac, Linux, Windows) Notepad++ ( Windows) Brackets ( Mac, Linux, Windows) Vim ( Linux) Trebedit (Android) Acode(Android)

Our first Script JS programs can be put in any part of a html document with the script tag


    alert( 'Hello world!' );

  <p>... End</p>

Save this and try it

External Scripts JS can also put in another file. JS files are saved with .js Let's write our hello world code again but with an external js file


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

script.js :

alert( 'Hello, world!' );

Awesome right?


Notice the source attribute ( src ), all I needed to do was write down the file name (properly called file path). In order to link files we have to specify path to the files. A path, the general form of the name of a file or directory, specifies a unique location in a file system. Types of paths There are two types of paths: Absolute path: An absolute or full path points to the same location in a file system, regardless of the current location is the file calling it (properly called the working directory ) Example: Imagine we stored all our files in a folder called files. The absolute path would be -

Relative path: a relative path starts from some given working directory, avoiding the need to provide the full absolute path. Example: Imagine we stored all our files in a folder called files. The relative path would be - ./script.js

If you have any questions, drop a comment. Good day ☺️

Note: 👏Unlike the name suggest JavaScript isn't related to Java at all.