Java and JavaScript differences. Learn to think in JavaScript!
Updated: 2016-09-25
When you switch from Java to JS and TypeScript is good to pay attention to this differences: [Post in continuous improvement …]
1. Equals are not equals
Coming from Java pay attention to the comparison operators in JavaScript. They behave differently from Java!
TypeScript requires explicit conversions and is much more similar to Java.
== |
=== |
2. Null is not undefined
In Java ‘null’ values are assigned to objects without value or undefined.
In JS and TS a variable without value is ‘undefined’ but not ‘null’. null is a value and can be assigned to a variable.
To add more complexity:
null == undefined : true null === undefined : false null == null : true null === null: true undefined === undefined : true