Table of Content

JavaScript Documentation



JavaScript (JS) is a lightweight interpreted (or just-in-time compiled) programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat. JavaScript is a prototype-based, multi-paradigm, single-threaded, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles.

Do not confuse JavaScript with the Java programming language — JavaScript is not "Interpreted Java". Both "Java" and "JavaScript" are trademarks or registered trademarks of Oracle in the U.S. and other countries. However, the two programming languages have very different syntax, semantics, and use.


What CAN in-browser JavaScript do?


Programming in JavaScript nowadays is "safe." Since it was originally developed for browsers that do not require it, it does not offer low-level access to memory or the CPU.

The environment in which JavaScript is used has a significant impact on its functionality. For example, Node.js provides methods that let JavaScript execute commands to read and write to any file, make network queries, and more.

All webpage alteration, user interaction, and webserver functionality may be achieved with in-browser JavaScript.

For instance, in-browser JavaScript is able to:

  • Add new HTML to the page, change the existing content, modify styles.
  • React to user actions, run on mouse clicks, pointer movements, key presses.
  • Send requests over the network to remote servers, download and upload files (so-called AJAX and COMET technologies).
  • Get and set cookies, ask questions to the visitor, show messages.
  • Remember the data on the client-side (“local storage”).

What CAN'T in-browser JavaScript do?


To ensure user safety, JavaScript's capabilities within the browser are restricted. The goal is to stop malicious websites from gaining access to personal data or damaging user information.

Examples of such restrictions include:

  • Websites using JavaScript might not be able to read, write, copy, or run programs from random files on the hard drive. It cannot access OS operations directly.

    It can interact with files in modern browsers, but access is restricted and granted only when specific actions are performed by the user, such as "dropping" a file into a browser window or choosing it using a <input> tag.

  • Generally speaking, tabs and windows are unaware of one another. They occasionally do, as when two windows are opened by JavaScript in one. However, even in this scenario, if the two pages originate from distinct websites (from a different domain, protocol, or port), JavaScript on one page might not be able to access the other.

    We refer to this as the "Same Origin Policy." In order to get around that, certain JavaScript code that manages data transmission must be present on both pages and must agree to it. That will be covered in the tutorial.

  • JavaScript may simply connect to the server that generated the current page via the internet. However, it is unable to receive data from other websites or domains. Although it is feasible, the remote side must explicitly consent, as stated in HTTP headers. That is, once more, a safety limitation.

What makes JavaScript UNIQUE?


There are at least three great things about JavaScript:

  • Full integration with HTML/CSS.
  • Simple things are done simply.
  • Supported by all major browsers and enabled by default.

Now that we are in th era of artificial intelligence, with the help JavaScript we can do data science and all stuff!