Introduction to JavaScript

What is JavaScript?

JavaScript was initially created to make web pages alive by handling interaction and DOM manipulation.
Initially, JavaScript was created to run only inside browsers.
Each browser has its own JavaScript engine that converts high-level JS to machine code to execute code.

Browser JS Engines

Different browsers have different JS engines:

  • V8: Chrome, Opera, Edge
  • SpiderMonkey: Firefox

JS on Servers

Later, this engine was carved out for server-side use, enabling JavaScript outside browsers.

What Can JavaScript Do?

The power of JavaScript depends on the environment: browser JavaScript and server JavaScript.

What Can In-Browser JavaScript Do?

Browser JavaScript does not provide low-level access to memory or the CPU, because it was initially created for browsers which do not require it.

In browser JavaScript can handle webpage manipulation, user interactions, cookies, local storage, and webserver communication.
Send requests over the network to remote servers, download and upload files (AJAX and COMET technologies).

What Can't In-Browser JavaScript Do?

Browser JavaScript has limits to keep users safe from harmful webpages stealing data or causing damage.

JavaScript cannot read or write files on the hard drive. It has no direct access to computer functions.
Browsers let it handle files only if you choose them—like dragging a file or picking one with an input button.

It cannot access camera, microphone, or other devices without clear permission. A webpage cannot secretly turn on your webcam and spy.

Different tabs or windows usually cannot see each other. Even if one opens another, they cannot share data if from different sites (this is the Same Origin Policy).

What Makes JavaScript Unique?

Three big strengths:

  • Full integration with HTML/CSS
  • Simple things done simply
  • Works in all major browsers by default

No other browser technology combines all three. That's why JavaScript dominates web interfaces.