JAVASCRIPT


JavaScript is an object-oriented scripting language used mainly in web design and interpreted in a web browser environment, but it can also be used to create stand-alone applications. Microsoft provides libraries for creating JS applications as part of the Windows Scripting Host environment. JavaScript was invented by Brendan Eich in 1995 and developed by Netscape. In 1996, ECMA started working on the language specification. ECMAScript6 released in 2015 is the latest official version of JavaScript.


ECMA
European Association for Standardizing Information and Communication Systems, the association was founded in 1961 and develops standards for information systems. Members of ECMA are companies producing, selling or developing information and telecommunication systems In Europe


ECMA Script
ECMAScript is an ECMA standardized object-oriented scripting programming language, the most famous implementations of which are JavaScript, JScript and ActionScript.


ES2015
In 2015 another, 6 version of EcmaScript was introduced. Introduced classes, modules, arrow functions, fixed a few inaccuracies that occurred in ES5 . This version is called ES6 or ES2015. ES2015 introduced two important new JavaScript keywords: let and const. So far, JavaScript has had two types of scope: global scope and scope of functions performed by the var keyword.

Example 1

var x = 2018;
// the variable "x" is global, it can be used anywhere
function fff()
{
// the variable 'x' can also be used in this function and it has the value '2018'

Example 2

function fff()
{
var x = 2018;
// the variable 'x' can be used here, it is a local variable
}
// the variable "x" outside a function is undefined and cannot be used,
// unless declared again somewhere else

Example 3

{
var x = 2018;
}
// the variable "x" can also be used outside this block
{
let y = 2019;
}
// variable "y" outside the block is not available,
// unless declared again somewhere else

Example 4

var x = 100;
// here x is 100
{
var x = 200;
// here x is 200
}
// here x is also 200, even though it is outside the block
var y = 100;
// here y is 100
{
let y = 200;
// here y is 200
}
// here y is 100 because it is outside the block

Example 5

var k = 7;
for (var k = 0; k < 100; k++)
{
}
// here k is 100
let j = 7;
for (var j = 0; j < 100; j++)
{
}
// here j is 7

If you write code in ES6, you can convert it to ES5 using the Babel compiler. Babel converts all const and let into var, arrow functions into normal functions, classes into prototype inheritance, etc. The code in ES6 can be converted to ES5 using the Babel compiler. This allows you to write code in the new standard and take advantage of the facilities without worrying about compatibility.


 SCRIPT PLACEMENT

  <script>
  instructions JavaSCript;
  </script>

The script can be placed practically anywhere in the HTML document, but for various reasons it is recommended to place in the section <HEAD>.

  <html>
  <head>
  <script type="text/javascript">
  script code
  </script>
  </head>
  <body>
  </body>
  </html>

The script can also be saved in a separate file with the .js extension, in which the whole code is written without any tags <script> , </script>, because these are the elements of html.

  <html>
  <head>
  <script type="text/javascript" src="file_name.js">
  </script>
  </head>
  <body>
  </body>
  </html>