Many people use the words Java and JavaScript interchangeably, or confuse the two. JavaScript supports most of Java's expression syntax and basic control flow constructs. JavaScript has a simple instance-based object model that still provides significant capabilities. JavaScript also supports functions, again without any special declarative requirements.
Functions can be properties of objects, executing as loosely typed methods.
JavaScript complements Java by exposing useful properties of Java applets to script authors. JavaScript statements can get and set exposed properties to query the state or alter the performance of an applet or plug-in. Java is an extension language designed, in particular, for fast execution and type safety. Type safety is reflected by being unable to cast a Java int into an object reference or to get at private memory by corrupting Java bytecodes. Java programs consist exclusively of classes and their methods.