java tutorial - Java vs javascript - java programming - learn java - java basics - java for beginners

Difference between Java vs JavaScript

Categories Java JavaScript
Execution Environment Java code is first compiled into class
files containing byte code
and then executes by JVM. Java is run
within JVM and needs JDK or JRE.
JavaScript code is directly executed by browser. JavaScript runs within browser and almost each and every modern browser support JavaScript.
Static vs Dynamic Typed language Java is a statically typed language. JavaScript is a dynamic typed language.
Support of Closures Java doesn't care for method as first class
citizen and only way to replicate
end is by using anonymous class.
JavaScript supports closures, in form of anonymous function. In simple words, you can pass a function as an argument to another function.
OOP Java is an Object Oriented
Programming language.It provides
packages to group related class
mutually, then provides much better
deployment control by using JAR,
WAR and EAR.
JavaScript also supports class and object; it's more like an object oriented scripting language. It's much easier to structure code of large enterprise application in Java then JavaScript.
Write Once Run Anywhere (WORA) The java used byte code for achieving the
platform independence concept.
It directly runs on the browser, but code written in JavaScript is subject to browser compatibility issue i.e. certain code that work in Mozilla Firefox, may not work in Internet Explorer 7 or 8.
Block vs Function based Scoping Java mostly uses block based scoping
i.e. a variable gone out of scope
immediately control comes out of the block,
unless until it’s not a
instance or class variable.
It mostly uses function based scoping; a variable is accessible in the function when they are declared. If you have a global variable as well as local variable with similar name, then the local variable will take precedence in JavaScript.
Constructors The Java constructors
contain some of the special properties
(e.g. constructor chaining and ensuring
that super class constructor runs previous to
sub class.
The JavaScript constructors are just one more function. Here, there is no special rules for constructors in JavaScript e.g. they cannot have return type or their name must be same as class.
NullPointerException Java have NullPointerException,
because Java is a statically
typed language.
JavaScript is much more forgiving than Java, you don't have NullPointerException in JavaScript, and your variable can accept different kinds of data because of JavaScript are dynamically typed language.
 java8 vs javascript

Learn Java - Java tutorial - java8 vs javascript - Java examples - Java programs

 java vs javascript

Learn Java - Java tutorial - java vs javascript - Java examples - Java programs

Related Searches to Java vs javascript