Java & java-script: Java & javascript have the only a name in common and nothing else. They are poles apart.
Java is basically a programming language that is an enhancement of C++ having a distinctive feature of being able to run on various machines and operating systems like Windows NT, Mac Os, Unix.
Javascript is an object-oriented language that allows the creation of interactive web pages. Java script allows user entries, which are loaded into an HTML form to be processed as required.
Java script offers several advantages to a web developer. The strengths of javascript can be easily and quickly used to extend the functionality of HTML pages.
Difference Between Java & JavaScript
Java
- Java is a statically typed language; JavaScript is dynamic.
- Java is class-based; JavaScript is prototype-based.
- Java constructors are special functions that can only be called at object creation; JavaScript “constructors” are just standard functions.
- Java requires all non-block statements to end with a semicolon; JavaScript inserts semicolons at the ends of certain lines.
- Java uses block-based scoping; JavaScript uses function-based scoping.
- Java has an implicit this scope for non-static methods, and implicit class scope; JavaScript has implicit global scope
JavaScript
- JavaScript supports closures; Java can simulate sort-of “closures” using anonymous classes. (Real closures may be supported in a future version of Java.)
- All JavaScript functions are variadic; Java functions are only variadic if explicitly marked.
- JavaScript prototypes can be redefined at runtime and have an immediate effect on all referring objects. Java classes cannot be redefined in a way that affects any existing object instances.
- JavaScript allows methods in an object to be redefined independently of its prototype (think eigenclasses in Ruby but on steroids); methods in a Java object are tied to its class, and cannot be redefined at runtime.