Learnitweb

Features of JavaScript

  1. JavaScript is prototype based object oriented scripting language. Functions are used as object constructors.
  2. JavaScript is dynamically typed scripting language.
  3. JavaScript supports run-time evaluation.
  4. JavaScript has features of functional programming. A function is a first-class in JavaScript.
  5. JavaScript supports implicit and explicit delegation.
  6. JavaScript supports regular expressions.
  7. JavaScript does not provide many features of its own. JavaScript relies on a run-time environment to provide these features like I/O, networking etc.
  8. JavaScript is case sensitive.
  9. JavaScript handles Date and Time.
  10. JavaScript has no distinction between a function definition and a method definition.

Capabilities of in-browser JavaScript

JavaScript is considered as “safe” programming language as it does not provide low-level access to CPU or memory. This is because JavaScript was intended to be used by browsers and browsers do not need it.

In-browser JavaScript can do everything related to a web page. JavaScript can help user to interact and manipulate a web page.

It is good to note that the capabilities of JavaScript also depend on the environment in which it executes. For example, Node.js supports functions which allow JavaScript to read/write files.

Following are some of the capabilities of in-browser JavaScript:

  • JavaScript can add HTML to a web page. It can modify existing content and the way it looks by modifying styles.
  • JavaScript can interact with servers by sending requests over the network and process response. JavaScript can download and upload files.
  • JavaScript can capture and react to user events on a web page like mouse click event or key press event.
  • JavaScript can save data on client-side (local storage).
  • JavaScript can get and set cookies and help personalize content for the users.

What can’t in-browser JavaScript do?

Web pages can be created by anyone and hosted by anyone. This page could be evil in it’s intention. A user can land on this page while searching for information on internet.

If JavaScript had low-level access, this page could get access to your system and information stored on it. In-browser JavaScript’s limited capabilities are for the good.

Following are some of the things which in-browser JavaScript can’t do:

  • JavaScript can not access (read, write) arbitrary files on the hard disk. In modern browsers, you can work with files like dropping a file into browser window, but the access is limited.
  • JavaScript can not execute programs as it does not have direct access to operating system functions.
  • JavaScript can not interact with devices like camera and microphone without user’s explicit permission.
  • A tab or window in a browser can not access and read information from another tab or window. Sometimes, they can like one tab opens another tab but even in this case JavaScript can not access another page if they have different protocol, page or port. So if a user has open a page https://www.test.com, then this page should not be able to access https://yourbank.com page and access it’s information.
  • If two pages from different domain want to share information then both pages should agree upon it and this requirement is handled specifically.