Javascript As A Beginner

Javascript As A Beginner

Starting your JS Journey

JavaScript is a dynamic programming language that's used for web development, in web applications, for game development, and lots more. It allows you to implement dynamic features on web pages that cannot be done with only HTML and CSS.

Many browsers use JavaScript as a scripting language for doing dynamic things on the web. Any time you see a click-to-show dropdown menu, extra content added to a page, and dynamically changing element colors on a page, to name a few features, you're seeing the effects of JavaScript.

What can in-browser JavaScript do?

Modern JavaScript is a “safe” programming language. It does not provide low-level access to memory or CPU, because it was initially created for browsers which do not require it.

JavaScript’s capabilities greatly depend on the environment it’s running in. For instance, Node.js supports functions that allow JavaScript to read/write arbitrary files, perform network requests, etc. JavaScript can do everything related to web page manipulation, interaction with the user, and the webserver.

JavaScript is able to:

  1. Add new HTML to the page, change the existing content, modify styles.

  2. React to user actions, run on mouse clicks, pointer movements, key presses.

  3. Send requests over the network to remote servers, download and upload files (so-called AJAX and COMET technologies).

  4. Get and set cookies, ask questions to the visitor, show messages.

What can't JavaScript do?

  1. JavaScript on a webpage may not read/write arbitrary files on the hard disk, copy them or execute programs. It has no direct access to OS functions.
  1. 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.

  2. There are ways to interact with camera/microphone and other devices, but they require a user’s explicit permission. So a JavaScript-enabled page may not sneakily enable a web-camera, observe the surroundings and send the information to the NSA.

  3. Different tabs/windows generally do not know about each other. Sometimes they do, for example when one window uses JavaScript to open the other one. But even in this case, JavaScript from one page may not access the other if they come from different sites (from a different domain, protocol or port).

JavaScript can easily communicate over the net to the server where the current page came from. But its ability to receive data from other sites/domains is crippled.

TUNE IN FOR MORE IN THE NEXT ARTICLE...