What is JavaScript?

JavaScript (or JS for short) is a programming language that was originally developed to make web pages interactive and dynamic. Nowadays, JavaScript is actively used to develop interactive websites and web applications, as well as high-load web servers (NodeJs). Programs written in JavaScript are commonly referred to as scripts. JavaScript code can be embedded directly into an HTML page, or linked to an HTML page through a separate .js file via script tag. JavaScript code is automatically executed by the user's browser when you open a web page.

JavaScript was originally created by Brendan Icke in 1995 for the Netscape browser and was called Mocha. But after several renames, it got its final name - JavaScript. At first, JavaScript had very little functionality and was mainly used to add interactivity to the page, but over time the functionality of the language has expanded significantly. In 1996, JavaScript was standardized by Ecma, an information, and communications technology standardization company. The specification itself was called ECMAScript, or ES for short. Basically, JavaScript is an implementation of the ECMAScript specification.

How to embed JavaScript in an HTML page?

For JavaScript to work in the user's browser, it must be inserted between the <script> and </script> tags in the HTML page.

JavaScript Hello World Example
<html>
<head>
   <title>JavaScript Hello World</title>
   <script>
      console.log('Hello World!');
   </script>   
</head>
<body>

<noscript>
   Your browser does not support JavaScript.
</noscript>

<h1>JavaScript Hello World Example</h1>

</body>
</html>

How to connect JavaScript file to an HTML page?

JavaScript code can also be placed in external files. JavaScript files usually have a .js extension, but this is not required. To include an external script, you need to put the JavaScript file name in the src attribute of the <script> tag. You can include external scripts inside the <head> or <body> tag of an HTML page.

JavaScript Hello World Example
<html>
<head>
   <title>JavaScript Hello World</title>
   <script src="app.js"></script>	
</head>
<body>

<noscript>
   Your browser does not support JavaScript.
</noscript>

<h1>JavaScript Hello World Example</h1>

</body>
</html>

And the app.js script file. Please note that the code does not contain <script> tags.

console.log('Hello World!');

External scripts can be linked either using absolute URLs (including another domain, such as a CDN), or using relative paths to the current web page.

JavaScript can run not only in a browser, but also on a server or any other device that has a special program called a JavaScript engine or JavaScript virtual machine. The engine is the part of the browser that converts HTML, CSS, JavaScript, images, and other information into an interactive image that is displayed on the browser window.

Different browsers have different engines. Each engine has its own name. For example:
Blink: Google Chrome, Opera and new versions of Microsoft Edge
Gecko: Mozilla Firefox.
WebKit: Safari
Trident and EdgeHTML: Internet Explorer and old versions of Microsoft Edge

What is the difference between Java and JavaScript?

Due to the similar name, many people mistakenly consider Java and JavaScript to be the same programming language, but this is not the case. Java and JavaScript are two completely different programming languages! Java is a programming language for creating separate compiled applications. JavaScript is for writing scripts that run in the browser and are embedded in HTML pages.

What makes JavaScript special?

Three things make JavaScript so special.
- Supported by all major browsers
- Full integration with HTML/CSS.
- Simple things are easy to do.