JavaScript is the name of a programming language : that is, a formal language that provides instructions to a computer (computer) to generate certain data. It is primarily used to produce interactive resources on a web page.
Due to its characteristics, JavaScript is an imperative, prototype-based and object-oriented language . It is generally used on the client side (known as client-side ), although there is also a server -side form of this language .
JavaScript Features
When we talk about imperative programming languages we are referring to those whose instructions must be executed one after another; that is, sequentially. It is important to clarify that the only exception occurs in loops, since the execution of all the instructions present there must be repeated until a certain condition is met.
It should be noted that the idea of flow control , in this framework, refers to the order of execution of the instructions detailed in the code. At a general level, as we indicated, JavaScript executes in a linear manner.
On the other hand, the reactive programming paradigm refers to working with finite flows of data in asynchrony so that they propagate with the production of changes in the application.
As mentioned above, JavaScript is also an object-oriented language , and this means that it complies with the paradigm that allows classes to be created and then instantiated as objects as many times as necessary. With this object-oriented programming, each of these has its properties and methods and can also inherit characteristics from other classes, among other possibilities.
To understand this concept we can think about real-world objects: we could define the class "chair" , indicating that it has a backrest, four legs and a seat, and then create as many chairs as we need, without having to redefine their characteristics. In turn, this class could inherit from a so-called "furniture" , where the properties common to all of them would be, and in this way thanks to inheritance we would avoid repeating them in "table" , "wardrobe" and "bed" , for example .
Its importance on the Web
The American programmer Brendan Eich is the creator of JavaScript . Eich developed the language under the name Mocha for the Netscape browser in the mid- 1990s . Over the years, JavaScript expanded to become one of the most used languages on the Web .
JavaScript allows you to incorporate all kinds of dynamic and interactive elements to a web page , such as a web counter, a clock and a calculator. The appearance of windows, animations and effects in texts can also be developed with this language that is suitable for the creation of multiple web services.
With JavaScript you can proceed to writing functions embedded in pages, interacting with their DOM (Document Object Model) . Thanks to this, data is sent to the server via AJAX without having to reload the page in question, to mention one possibility.
The presence of these elements running on the client's computer can pose great risks to web security, and that is why it is possible to disable them. Pages with countless videos and ads that play automatically are an example of JavaScript being used invasively. It should be noted, however, that the scripts used on a site are not able to access information that is sent to a site on a different domain (such as cookies, passwords or usernames).
JavaScript objects
In this area of web programming, JavaScript objects can be created by the developer, but there are also many that are specific to this environment, such as "DIV" , "A" , "P" and "TABLE" , among others. others. Since each of them shares their traits with others of the same class and can be used as many times as we want, we consider them objects . Through JavaScript it is possible to access its properties and manipulate them in more complex and dynamic ways than in HTML code.
Currently, all browsers ( Chrome , Firefox , Safari , Edge ) support JavaScript . This means that programs can directly interpret the code that appears on a web page, which is why JavaScript is an interpreted language . This language is also used in widgets and in PDF documents , for example.
The concept of interpreted language , on the other hand, refers to the fact that lines of code are translated into machine language as it becomes necessary, and not all at once before the execution of the program, as occurs with languages. compiled (such as C++ or C# , for example).
Debugging the code
Debugging JavaScript code is the process of discovering and fixing bugs. This can be done from the browser console .
The console displays various messages, in addition to code debuggers. Likewise, it is used to execute commands and interact with the page.
JavaScript vs. Java
It is important not to confuse JavaScript with Java : they are different languages, each with its own particular characteristics.
In the case of Java , it was created by James Gosling and published as part of a Sun Microsystems platform in 1995 .