JavaScript is a simpler language than Java


JavaScript is a simpler language than Java, with fewer built-in functions, yet it is still extremely expressive.
Java has a much larger set of capabilities, yet it is also a bit more difficult to use.

If you have ever seen any Java code


If you have ever seen any Java code you have probably noticed that it bears a substantial resemblance to JavaScript. A large part of the Java language is identical to JavaScript.
There are several significant differences between Java and JavaScript that are critical in learning how to effectively use both tools. These differences can be grouped into the following three categories that are the object models,Interactions with the browser environment,and the Language differences.

JavaScript objects are used to access the


JavaScript objects are used to access the built-in mathematical, string, and date functions. JavaScript objects are also used to access and manipulate HTML elements inside JavaScript code.
Java takes this object-oriented approach even further. Everything in Java is based on objects and their properties and methods.

In JavaScript you often create functions


In JavaScript you often create functions that are methods of your own objects. You are also perfectly free to have functions that are not methods.
Event handler functions are usually not method functions, for example. In Java, all functions must be methods of some object, and all variables must be properties of some object.

In JavaScript the focus is on responding to events


In JavaScript the focus is on responding to events. A user action produces an event that triggers a JavaScript event handler, which does something useful.
In Java, user events are handled very differently. When the user loads a Web page containing Java code, in the form of a Java applet, the browser tells the applet to start. When the user leaves that page the applet is told to stop.

While JavaScript code is ultimately event driven


While JavaScript code is ultimately event driven, and intimately tied to its HTML environment, Java applets are much more independent. An applet may respond to a mouse click within its active area, but it won’t be listening for the sound of a Submit button being pressed.
An applet is a little application that lives in its own world, for the most part. JavaScript code is more like a Dynamically Loaded Library which is activated in response to something.

JavaScript takes a very relaxed attitude towards variables and functions


JavaScript takes a very relaxed attitude towards variables and functions. Variables are typeless, and the distinction between functions, objects, and arrays is blurry at best. By contrast, Java is an extremely strict language.
All Java variables have an explicit data type. Types may only be converted to one another under very well defined conditions, and only by using explicit type conversion functions. Java also enforces static name binding, instead of JavaScript’s dynamic binding. It is impossible to reference an undefined function.

Java is actually a very small language when compared with


Java is actually a very small language when compared with other object-oriented programming languages such as C++. Nevertheless, it has a large number of capabilities.
The extensive set of built-in functions and objects known as the Java class hierarchy, for example, implements an extremely rich and powerful set of tools for image manipulation and network access, among other things.

Java variables must be explicitly declared


Java variables must be explicitly declared with a particular data type. Java is very similar to the C and C++ programming languages in terms of the types it supports.
Java, however, rigidly specifies the size and representation of its various types so that there can be no confusion. If you have ever tried to port a C program from a DOS or Windows environment with 16-bit integers to a UNIX or Windows-NT environment with 32-bit integers, you know from firsthand experience how frustrating such low-level problems can be.

There are several differences between the object models of Java and JavaScript


There are several differences between the object models of Java and JavaScript, as well as their terminologies.Java refers to its objects as classes, unlike JavaScript.
Java object members are referred to as instance variables, rather than properties. Instances and methods have the same meaning in both languages.