Difference between Javascript and Typescript
Difference between Javascript and Typescript:
Javascript | Typescript |
var myVar = ‘hello’; myVar = 10; console.log(myVar); // prints 10 |
let myVar = ‘hello’; myVar = 10; console.log(myVar) // we get the error here stating //Type ‘number’ is not assignable to type ‘string’ |
We dont have a type number only in javascript. | Typescript does not have float/double types, everything is considered as type number only (like 10, 11.2, 27.8000). |
As types are not supported in javascript, explicit assignments will also be not possible. | Explicit assignment is possible let name:string = ‘javadomain’; let price:number = 100000; |
We dont have any types like any, and also it even does not maintain the types internally based on the initialization assignments | we can have the variable with type ‘any’, then which is allowed to hold any types like string/number etc. |
Javascript does not have type tuple object. | Tuples can be used to have the mixed type contents in an array. |
[table id=5 /]