Introduction to Typescript and Javascript

Posted By : Nutan Verma | 23-Dec-2020

Introduction

The Typescript was developed by Anders Hejlsberg, who is also the core member in developing the c#,
the current stable version or typescript is 3.2 which was developed in September 2018

Features if Typescript

  • Operating system (Linux, Windows,macOS) supports installation of Typescript
  • We can write object-oriented code for client and server-side as it supports some features like Interfaces, classes, and modules
  • We can find errors at the time of writing the code, without running the script, as  it does Static Type checking
  • We can use it for manipulating the DOM, like adding or removing the elements
  • It includes features of  ECMAScript 2015, which provide features of the class, Arrow function, interface

Components of Typescript

1)Language: It comprises elements like keyword, type annotations, and syntax

2)Typescript Compiler: It converts typescript to its javascript equivalent, it also does parsing and type checking of typescript code to javascript code

3)Typescript Language services: It exposes an additional layer around the core compiler pipeline, editor-like applications. It also supports some standard typical editor operations like colorization, statement completion, code formatting and outlining, signature help, etc. The language service supports the common set of typical editor operations.

 

Also Read: Overview Of Angular version 10

 

How static Typing works?

function addFive(num) {
return num + 5
}

if we pass addFive("Hi"), the function will return "Hi5"

or if pass addFive("5"), the function will return "55"

function addFive(num: number) {
    return num + 5
}
 
Here in the above code if we will pass "5" or "Hi" this will now throw an error 
and if we will pass addFive(5) this will give us the desired result of 10
 
Some comparisions between typescript and Javascript
  • Typescript is an object-oriented language whearas javascript is the scripting language
  • It has a feature named static typing whereas javascript doesn't have such feature
  • Typescript gives support to module whereas javascript doesn't
  • Typescript support operational parameter function whereas javascript doesn't

List of primitive data types in typescript

  1. Number
  2. String
  3. boolean
  4. Null
  5. Undefined
  6. Void

 

Also Read: Asynchronous Javascript

 

Declare a variable in Typescript

var [identifier] : [type-annotation] = value; //Declaring type and value in a single statement

var [identifier] : [type-annotation]; //Declaring type without value

var [identifier] = value; //Declaring its value without type

var [identifier]; //Declaring without value and type

 

We are a 360-degree software development company that provides complete web and mobile app development solutions for varied project requirements. Our end-to-end SaaS app development services address your mission-critical project requirements through scalable, responsive, and feature-rich software applications that are easy to scale. We carefully analyze your project requirements and formulate effective strategies to build enterprise-grade web and mobile applications for multiple platforms. For more info, contact us at [email protected]

 

About Author

Author Image
Nutan Verma

She works as a Frontend Developer. She keeps looking for challenges which demands the best of her professional ability in terms of technical, analytical skills. She is always energetic and competent.

Request for Proposal

Name is required

Comment is required

Sending message..