Skip to main content
Welcome to this first post, which will serve as an introduction to this important, versatile, and recognized programming language with which you will increase your opportunities as a programmer or web developer. Let’s start!

What is JavaScript?

The JavaScript programming language was originally created in order to «make web pages alive», which is to say that it gives dynamism to HTML web pages today. There are many different use cases for this programming language, from web scraping using JavaScript to creating conversion sites, the opportunities are limitless.

Programs made in this language are known as scripts. These programs can be written directly in our HTML because we can embed it in our initial HTML layout, either as a call to an external document, or by calling another section of the same document, and this is executed automatically as the web page loads.

The scripts are provided and run as plain text. This means that the browser is able to interpret the JS code immediately, so it does not need special preparation or compilation to run.

By this we can say that JavaScript is different from Java, since the latter requires a compiler to be executed.

Currently, JavaScript can run not only in the browser, but also on the server, or on any device that has a special program called a JavaScript engine.

The browser has an embedded engine, sometimes it is also called a «JavaScript virtual machine».

Different engines have different «code names», for example:

V8 – in Chrome and Opera.
SpiderMonkey – in Firefox.
… There are other code names like «Trident», «Chakra» for different versions of IE, «ChakraCore» for Microsoft Edge, «Nitro» and «SquirrelFish» for Safari, and so on.

The above terms are good to remember, because they are used in developer articles on the Internet. And maybe one day you will need them too. For example, if «an X feature is supported by V8», then it probably works in Chrome and Opera.

What can JavaScript do in your browser?

Modern JavaScript is a programming language that we can call «safe.» JS does not provide low-level access to memory or CPU, as it was initially created for browsers that do not require it.

The capabilities are highly dependent on the environment running JavaScript. For example, Node.JS supports functions that allow JavaScript to read and / or write arbitrary files, make network requests, etc.

JavaScript in the browser can do everything related to the manipulation of the web page, the interaction with the user and the web server.

For example, JavaScript in the browser is capable of doing the following:

  • Add new HTML to the page, change existing content, modify styles, etc.
  • Reacts to user actions, executes mouse clicks, pointer movements, keystrokes, among others.
  • It sends requests over the network to remote servers, downloading and uploading files (so-called AJAX and COMET technologies).
  • It gets and sets cookies, it can ask questions of the web page visitor, and it can even display messages.
    Save the data on the client side («local storage»).

What CANNOT JavaScript do in the browser?

JavaScript capabilities in the browser are limited for the sake of user safety. The aim is to prevent a malicious website from accessing private information or damaging user data.

Here below I list some of the restrictions that JS has in your browser.

  • JavaScript on a web page may not be able to read / write arbitrary files to the hard drive, copy them, or run programs. And you don’t have direct access to operating system functions either.
  • Modern browsers allow you to work with files, but access is limited and only provided if the user performs certain actions, such as «dropping» a file into a browser window, or selecting it using an <input> tag.
    There are ways to interact with the camera and / or microphone, and other devices, but they require explicit permission from the user. Therefore, a JavaScript-enabled page might not sneakily enable a webcam, observe the environment, and submit the information to the NSA.
  • The different tabs or windows generally do not know each other. Sometimes they do, for example when one window uses JavaScript to open the other. But even in this case, the JavaScript on one page may not be able to access the other if they come from different sites (from a different domain, protocol, or port). This is called the «Same Origin Policy.» To avoid this, both pages must contain a special JavaScript code that takes care of the data exchange.

The limitation is again for the safety of the user. A page on that a user has opened must not be able to access