

To work around that, both pages must agree for data exchange and must contain special JavaScript code that handles it. But even in this case, JavaScript from one page may not access the other page if they come from different sites (from a different domain, protocol or port). Sometimes they do, for example when one window uses JavaScript to open the other one. So a JavaScript-enabled page may not sneakily enable a web-camera, observe the surroundings and send the information to the NSA.ĭifferent tabs/windows generally do not know about each other. There are ways to interact with the camera/microphone and other devices, but they require a user’s explicit permission. Modern browsers allow it to work with files, but the access is limited and only provided if the user does certain actions, like “dropping” a file into a browser window or selecting it via an tag. JavaScript on a webpage may not read/write arbitrary files on the hard disk, copy them or execute programs. The aim is to prevent an evil webpage from accessing private information or harming the user’s data. JavaScript’s abilities in the browser are limited to protect the user’s safety. Remember the data on the client-side (“local storage”).Get and set cookies, ask questions to the visitor, show messages.Send requests over the network to remote servers, download and upload files (so-called AJAX and COMET technologies).


It does not provide low-level access to memory or the CPU, because it was initially created for browsers which do not require it. Modern JavaScript is a “safe” programming language. It even watches the compiled script as it runs, analyzes the data that flows through it, and further optimizes the machine code based on that knowledge. The engine applies optimizations at each step of the process.

Today, JavaScript can execute not only in the browser, but also on the server, or actually on any device that has a special program called the JavaScript engine. But Java was very popular at that time, so it was decided that positioning a new language as a “younger brother” of Java would help.īut as it evolved, JavaScript became a fully independent language with its own specification called ECMAScript, and now it has no relation to Java at all. When JavaScript was created, it initially had another name: “LiveScript”.
