Introduction
In this article we will learn why TypeScript? Why Typescript become more famous and how can the TypeScript different from JabvaScript. What is the basic difference in syntax's of both languages. Should we follow TypeScript or JavaScript.
Previous Updates
In previous articles we have learnt what is TypeScript and How to Install this on VS2015 .AngularJS basics, Difference IEnumerabe vs IQueryable. What is Cursor in sql and use of cursor. Best basic C# interview questions.
Why JavaScript Complicated For OOP Based Developers
JavaScript is most famous language in 2017. All browsers compatible and easy to learn. But if you are new in javascript then it is ok but if you came across the object oriented field then it will create some complexity to you
If you have to create a class in JavaScript then you create a Function sounds unusual to Object Oriented background developer ,also if you need to create properties then you can define this with this keyword and if you want to create a function then you can achieve this differently in JavaScript. Below Example
<script >
function Employee() // Employee Class
{
this.EmpId = ""; // Property
this.EmpName = "";
this.ValidateEmp = function () //Function with in Class
{
alert('Validate Successfully.')
}
}
</script>
|
So if you are Coming from Object Oriented background and when you first look the above code you will be confused what is that ? for reduce this JavaScript complexity Micorosoft invented the TypeScript for Object oriented developers to feel them cool while writing code.
TypeScript says that it will very difficult to grasp the all concept of JavaScript so that i will provide you ability to write your class properties methods as you written in C# or Java(Object Oriented Programming) and it will compiled your TypeScriptCode into a plane JavaScriptFile. Below Example
class Employee
{
public EmpName: string = "";
}
|
When we save this type script file it will autometic generate a js file with same name and create a Javascript cocde for above given TypeScript Code.
Here you can easily saw how easy type script is which creates javascript code file for you automatically.
In this next Update we will learn how to done programming with TypeScript from Scratch. Keep reading keep sharing. Happy Programming.
0 comments:
Post a Comment