1

I was just reading one of the JavaScript resource and found following statement written.

javascript can not automatically write to hard disk But Java can do so.

Can somebody please elaborate?

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Vineet kaushik
  • 351
  • 3
  • 4

1 Answers1

4

Javascript is a scripting language that lives inside the browser. As such it is bound and restricted by the browser.

Java on the other hand is being executed as a stand alone application. Having all the rights of the person currently logged in. This means that if the logged in user has rights to write to the hard drive so does the java program.

Luckily javascript does not get those rights from the browser. The major reason for this is security. You do not want a virus written to your hard drive while just browsing a website.

And indeed Javascript is by no means Java, it is not even close to it.

Niki van Stein
  • 10,564
  • 3
  • 29
  • 62
  • 1
    *"Javascript is a scripting language that lives inside the browser"* - careful, we're in the 21st century now. Javascript is a general purpose language used for many solutions, including on the server (Node.js), in the NoSQL database (MongoDB) and even inside the Java Virtual Machine (Nashorn). – Gimby Feb 16 '16 at 09:40
  • @Gimby good point. I was speaking of the traditional way to use javascript. When running on servers etc it also becomes possible to write to disk. – Niki van Stein Feb 16 '16 at 11:16
  • Indeedy. And that same sandbox would pretty much also apply to Java when run as a plugin within the browser, although there you have some freedom to open it up through the client granting access. In javascript land you can only go as far as the local storage API. – Gimby Feb 16 '16 at 11:42