DEV Community

Vijay SRJ
Vijay SRJ

Posted on

How does Number data type differ in Java and Javascript?

Brendan Eich , while creating Javascript took a great influence from Java.
In fact he was asked to create the Java language on the browser by the company Netscape.

So though Javascript has a lot of similarities with Java , it varies widely in other aspects.

With respect to numbers , Javascript treats Numbers differently from Java in these ways:

  1. All numbers are floating point numbers in Javascript
  2. You can represent 'Not a Number' in Javascript
  3. You can represent Infinity in Javascript
  4. You can convert a string to number using the '+' symbol in Javascript.

Explained with examples here:

https://fullstackdeveloper.guru/2021/04/30/how-do-numbers-differ-in-javascript-and-java/

Top comments (0)