- Get link
- X
- Other Apps
- Get link
- X
- Other Apps
JavaScript is the scripting language we are using in the browser
to make our websites reactive.
Typescript is a super-set of JavaScript. It is an upgraded version of ES5. But TypeScript doesn’t run in the browser. The code written in typescript is compiled to JavaScript, which then runs in the browser.
Typescript is a super-set of JavaScript. It is an upgraded version of ES5. But TypeScript doesn’t run in the browser. The code written in typescript is compiled to JavaScript, which then runs in the browser.
The point to be noted here is that, the developer has the freedom
of using syntax of JavaScript in his/her TypeScript code.
The main feature the TypeScript offers is that, it is a strongly typed language, which means you have to be specific about which type of variable you have declared. It basically brings in more strictness in our code.
Syntax in TypeScript-
let myName = 'visualpath'; //declaring variable of type string in TS
myName = 28;
Now when we will compile this code, it will give an error message in Line 2-
Type ‘number’ is not assignable to type ‘string’
*******Coding in JavaScript-
var myName = 'Siddharth';
var myName = 29; //no error
The main feature the TypeScript offers is that, it is a strongly typed language, which means you have to be specific about which type of variable you have declared. It basically brings in more strictness in our code.
Syntax in TypeScript-
let myName = 'visualpath'; //declaring variable of type string in TS
myName = 28;
Now when we will compile this code, it will give an error message in Line 2-
Type ‘number’ is not assignable to type ‘string’
*******Coding in JavaScript-
var myName = 'Siddharth';
var myName = 29; //no error
- Get link
- X
- Other Apps
Comments
Post a Comment